]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
minimal-config changes; $"..." support is now a configuration option
authorChet Ramey <chet.ramey@case.edu>
Wed, 1 Dec 2021 21:40:52 +0000 (16:40 -0500)
committerChet Ramey <chet.ramey@case.edu>
Wed, 1 Dec 2021 21:40:52 +0000 (16:40 -0500)
19 files changed:
CWRU/CWRU.chlog
builtins/set.def
builtins/wait.def
config.h.in
configure
configure.ac
doc/bashref.info
doc/bashref.texi
examples/loadables/getconf.c
examples/loadables/getconf.h
examples/loadables/sleep.c
lib/sh/shquote.c
locale.c
parse.y
shell.c
subst.c
tests/200 [new file with mode: 0644]
tests/getopts10.sub
tests/run-minimal

index f9476b20ab851b9b338243137d84b502babce50a..cbe7d89df7d513eced6abf48951fe09559de5cc4 100644 (file)
@@ -2543,4 +2543,38 @@ examples/loadables/sleep.c
          away and "dhms" appears in the format string. Don't return
          EX_DISKFALLBACK under any circumstances
 
+                                  11/30
+                                  -----
+
+builtins/wait.def
+       - wait_builtin: refer to unset_waitlist only if JOB_CONTROL is enabled.
+         Report from Joel Ebel <jbebel@google.com>
+
+parse.y,builtins/set.def
+       - changes for minimal config restrictions
+
+configure.ac,config.h.in
+       - --enable-translatable-strings: new configuration option to allow
+         $"..." support to be compiled in or out; not included in the minimal
+         shell configuration
+
+shell.c
+       - main: don't include any of the dump-strings options if
+         TRANSLATABLE_STRINGS is not defined
 
+lib/sh/shquote.c
+       - sh_backslash_quote_for_double_quotes: needed for translatable strings
+
+parse.y
+       - support for translating $"..." strings now conditional on
+         TRANSLATABLE_STRINGS
+
+locale.c
+       - locale_expand: now conditional on TRANSLATABLE_STRINGS
+
+subst.c
+       - expand_string_dollar_quote: support for $"..." now conditional on
+         TRANSLATABLE_STRINGS
+
+doc/bashref.texi
+       - --enable-translatable-strings: document new configuration option
index a50764b6524cdf37c3c6ff0b3d5c9a57890b63f2..44f17691966d31d1f713edbd60b693e9cfbc793d 100644 (file)
@@ -872,7 +872,9 @@ unset_builtin (list)
   else if (unset_function && nameref)
     nameref = 0;
 
+#if defined (ARRAY_VARS)
   base_vflags = assoc_expand_once ? VA_NOEXPAND : 0;
+#endif
 
   while (list)
     {
index 26578a4d4c0ea19cb92ce66c1db71ca887271e2d..b4758404ab78be889c5ea2321e00fecd1c296b41 100644 (file)
@@ -187,8 +187,10 @@ wait_builtin (list)
       last_command_exit_signal = wait_signal_received;
       status = 128 + wait_signal_received;
       wait_sigint_cleanup ();
+#if defined (JOB_CONTROL)
       if (wflags & JWAIT_WAITING)
        unset_waitlist ();
+#endif
       WAIT_RETURN (status);
     }
 
index a0bfa9ebe5d80acd5ee3d769fb1c00424f9413cb..d6d52930bde22335cf74cee08a436c1691e8e172 100644 (file)
    in array2.c */
 #undef ALT_ARRAY_IMPLEMENTATION
 
+/* Support for $"..." translatable strings. */
+#undef TRANSLATABLE_STRINGS
+
 /* Additional defines for configuring lib/intl, maintained by autoscan/autoheader */
 
 /* Define if you have the <argz.h> header file. */
index 0545990c6dc790f3ac3d19e043c3f6089c6a20ff..d2654f780b15747300ffe9ce12cb7988f483891e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac for Bash 5.2, version 5.036.
+# From configure.ac for Bash 5.2, version 5.038.
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.71 for bash 5.2-devel.
 #
@@ -887,6 +887,7 @@ enable_select
 enable_separate_helpfiles
 enable_single_help_strings
 enable_strict_posix_default
+enable_translatable_strings
 enable_usg_echo_default
 enable_xpg_echo_default
 enable_mem_scramble
@@ -1606,6 +1607,8 @@ Optional Features:
                           translation
   --enable-strict-posix-default
                           configure bash to be posix-conformant by default
+  --enable-translatable-strings
+                          include support for $"..." translatable strings
   --enable-usg-echo-default
                           a synonym for --enable-xpg-echo-default
   --enable-xpg-echo-default
@@ -3411,6 +3414,7 @@ opt_globascii_default=yes
 opt_function_import=yes
 opt_dev_fd_stat_broken=no
 opt_alt_array_impl=no
+opt_translatable_strings=yes
 
 ARRAY_O=array.o
 
@@ -3434,6 +3438,7 @@ if test $opt_minimal_config = yes; then
        opt_net_redirs=no opt_progcomp=no opt_separate_help=no
        opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
        opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no
+       opt_translatable_strings=no
        opt_globascii_default=yes
 fi
 
@@ -3653,6 +3658,12 @@ then :
   enableval=$enable_strict_posix_default; opt_strict_posix=$enableval
 fi
 
+# Check whether --enable-translatable-strings was given.
+if test ${enable_translatable_strings+y}
+then :
+  enableval=$enable_translatable_strings; opt_translatable_strings=$enableval
+fi
+
 # Check whether --enable-usg-echo-default was given.
 if test ${enable_usg_echo_default+y}
 then :
@@ -3822,6 +3833,10 @@ if test $opt_alt_array_impl = yes; then
 printf "%s\n" "#define ALT_ARRAY_IMPLEMENTATION 1" >>confdefs.h
 
 ARRAY_O=array2.o
+fi
+if test $opt_translatable_strings = yes; then
+printf "%s\n" "#define TRANSLATABLE_STRINGS 1" >>confdefs.h
+
 fi
 
 if test $opt_memscramble = yes; then
index 53f41a2480df760140e2bf237f75c38011d2a3a5..801b324d273451158970bea113ba3e3c83fdffeb 100644 (file)
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
 #   You should have received a copy of the GNU General Public License
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-AC_REVISION([for Bash 5.2, version 5.036])dnl
+AC_REVISION([for Bash 5.2, version 5.038])dnl
 
 define(bashvers, 5.2)
 define(relstatus, devel)
@@ -183,6 +183,7 @@ opt_globascii_default=yes
 opt_function_import=yes
 opt_dev_fd_stat_broken=no
 opt_alt_array_impl=no
+opt_translatable_strings=yes
 
 dnl modified by alternate array implementation option
 ARRAY_O=array.o
@@ -206,6 +207,7 @@ if test $opt_minimal_config = yes; then
        opt_net_redirs=no opt_progcomp=no opt_separate_help=no
        opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
        opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no
+       opt_translatable_strings=no
        opt_globascii_default=yes
 fi
 
@@ -245,6 +247,7 @@ AC_ARG_ENABLE(select, AS_HELP_STRING([--enable-select], [include select command]
 AC_ARG_ENABLE(separate-helpfiles, AS_HELP_STRING([--enable-separate-helpfiles], [use external files for help builtin documentation]), opt_separate_help=$enableval)
 AC_ARG_ENABLE(single-help-strings, AS_HELP_STRING([--enable-single-help-strings], [store help documentation as a single string to ease translation]), opt_single_longdoc_strings=$enableval)
 AC_ARG_ENABLE(strict-posix-default, AS_HELP_STRING([--enable-strict-posix-default], [configure bash to be posix-conformant by default]), opt_strict_posix=$enableval)
+AC_ARG_ENABLE(translatable-strings, AS_HELP_STRING([--enable-translatable-strings], [include support for $"..." translatable strings]), opt_translatable_strings=$enableval)
 AC_ARG_ENABLE(usg-echo-default, AS_HELP_STRING([--enable-usg-echo-default], [a synonym for --enable-xpg-echo-default]), opt_xpg_echo=$enableval)
 AC_ARG_ENABLE(xpg-echo-default, AS_HELP_STRING([--enable-xpg-echo-default], [make the echo builtin expand escape sequences by default]), opt_xpg_echo=$enableval)
 
@@ -363,6 +366,9 @@ if test $opt_alt_array_impl = yes; then
 AC_DEFINE(ALT_ARRAY_IMPLEMENTATION)
 ARRAY_O=array2.o
 fi
+if test $opt_translatable_strings = yes; then
+AC_DEFINE(TRANSLATABLE_STRINGS)
+fi
 
 if test $opt_memscramble = yes; then
 AC_DEFINE(MEMSCRAMBLE)
index d0af3c409c8902f53617155092f8d64ee3465755..8523de7904b3511fc517553aa1f1c82a9020300f 100644 (file)
@@ -10720,6 +10720,10 @@ does not provide the necessary support.
 '--enable-strict-posix-default'
      Make Bash POSIX-conformant by default (*note Bash POSIX Mode::).
 
+'--enable-translatable-strings'
+     Enable support for '$"STRING"' translatable strings (*note Locale
+     Translation::).
+
 '--enable-usg-echo-default'
      A synonym for '--enable-xpg-echo-default'.
 
@@ -12516,15 +12520,15 @@ Node: Specifying the System Type\7f448568
 Node: Sharing Defaults\7f449284
 Node: Operation Controls\7f449957
 Node: Optional Features\7f450915
-Node: Reporting Bugs\7f462008
-Node: Major Differences From The Bourne Shell\7f463283
-Node: GNU Free Documentation License\7f480133
-Node: Indexes\7f505310
-Node: Builtin Index\7f505764
-Node: Reserved Word Index\7f512591
-Node: Variable Index\7f515039
-Node: Function Index\7f531531
-Node: Concept Index\7f545315
+Node: Reporting Bugs\7f462133
+Node: Major Differences From The Bourne Shell\7f463408
+Node: GNU Free Documentation License\7f480258
+Node: Indexes\7f505435
+Node: Builtin Index\7f505889
+Node: Reserved Word Index\7f512716
+Node: Variable Index\7f515164
+Node: Function Index\7f531656
+Node: Concept Index\7f545440
 \1f
 End Tag Table
 
index 02a2992ee4e10d40d0ceffa9892147295f9ca3de..bd45aa555e2d5c6057367de936657c93b41b3d69 100644 (file)
@@ -9428,6 +9428,10 @@ literals.
 @item --enable-strict-posix-default
 Make Bash @sc{posix}-conformant by default (@pxref{Bash POSIX Mode}).
 
+@item --enable-translatable-strings
+Enable support for @code{$"@var{string}"} translatable strings
+(@pxref{Locale Translation}).
+
 @item --enable-usg-echo-default
 A synonym for @code{--enable-xpg-echo-default}.
 
index 82f80bb20cadcb00ecf64bbf7795b517a71fee3b..8ca13ca5a0973c8c37c23ab8d4655e47ea275d97 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software; you can redistribute it and/or modify
index ed4bbb944fdc841cc2566f63a0a7b1439514b168..b8b9f1026d83e250bf7eea54a724e5dbcce935b8 100644 (file)
@@ -1,3 +1,20 @@
+/*
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   
+   This file is part of GNU Bash.
+   Bash is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   Bash is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Bash.  If not, see <http://www.gnu.org/licenses/>.
+*/
 /* getconf.h -- replacement definitions for ones the system doesn't provide
    and don't appear in <typemax.h> */
 
index 32055ac1359abcd9fc38f99a2f95d7298c287d70..204601f5282eda3091e278654b71e99ace331623 100644 (file)
@@ -91,7 +91,7 @@ parse_gnutimefmt (char *string, long *sp, long *up)
 
                /* multiply the accumulated value by the multiplier */
                t = accumusec * mult;
-               accumsec = accumsec * mult + t / 1000000;
+               accumsec = accumsec * mult + (t / 1000000);
                accumusec = t % 1000000;
 
                /* add to running total */
index 680f84ed87e80502a69591bd85b88784bd6ef584..55310ce45bb5b243e6faf026593237d34fea44bb 100644 (file)
@@ -311,7 +311,7 @@ sh_backslash_quote (string, table, flags)
   return (result);
 }
 
-#if defined (PROMPT_STRING_DECODE)
+#if defined (PROMPT_STRING_DECODE) || defined (TRANSLATABLE_STRINGS)
 /* Quote characters that get special treatment when in double quotes in STRING
    using backslashes.  Return a new string. */
 char *
index 8d13910d5f3d79b50e2b82bcf5e256b822d105b1..fabf7b12537cf0ffb74e6c5de68ae3af4add9af4 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -400,6 +400,7 @@ reset_locale_vars ()
   return 1;
 }
 
+#if defined (TRANSLATABLE_STRINGS)
 /* Translate the contents of STRING, a $"..." quoted string, according
    to the current locale.  In the `C' or `POSIX' locale, or if gettext()
    is not available, the passed string is returned unchanged.  The
@@ -567,6 +568,7 @@ locale_expand (string, start, end, lineno, lenp)
       return (temp);
     }
 }
+#endif
 
 /* Set every character in the <blank> character class to be a shell break
    character for the lexical analyzer when the locale changes. */
diff --git a/parse.y b/parse.y
index 6e1770abc7f08df26790e3ac5c0ffa26bb1b44de..990fcc4695d619a259ed35f9ec5d540ee1e7b260 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -118,8 +118,10 @@ typedef void *alias_t;
 extern int extended_glob;
 #endif
 
+#if defined (TRANSLATABLE_STRINGS)
 extern int dump_translatable_strings, dump_po_strings;
 extern int singlequote_translations;
+#endif /* TRANSLATABLE_STRINGS */
 
 #if !defined (errno)
 extern int errno;
@@ -152,11 +154,9 @@ static int shell_getc PARAMS((int));
 static void shell_ungetc PARAMS((int));
 static void discard_until PARAMS((int));
 
-#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
 static void push_string PARAMS((char *, int, alias_t *));
 static void pop_string PARAMS((void));
 static void free_string_list PARAMS((void));
-#endif
 
 static char *read_a_line PARAMS((int));
 
@@ -1848,8 +1848,6 @@ restore_token_state (ts)
  *     everything between a `;;' and the next `)' or `esac'
  */
 
-#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
-
 #define END_OF_ALIAS 0
 
 /*
@@ -1945,10 +1943,12 @@ pop_string ()
   shell_input_line_len = pushed_string_list->saved_line_len;
   shell_input_line_terminator = pushed_string_list->saved_line_terminator;
 
+#if defined (ALIAS)
   if (pushed_string_list->expand_alias)
     parser_state |= PST_ALEXPNEXT;
   else
     parser_state &= ~PST_ALEXPNEXT;
+#endif
 
   t = pushed_string_list;
   pushed_string_list = pushed_string_list->next;
@@ -1982,8 +1982,6 @@ free_string_list ()
   pushed_string_list = (STRING_SAVER *)NULL;
 }
 
-#endif /* ALIAS || DPAREN_ARITHMETIC */
-
 void
 free_pushed_string_input ()
 {
@@ -2650,7 +2648,9 @@ next_alias_char:
 #endif
 
 pop_alias:
-  /* This case works for PSH_DPAREN as well */
+#endif /* ALIAS || DPAREN_ARITHMETIC */
+  /* This case works for PSH_DPAREN as well as the shell_ungets() case that uses
+     push_string */
   if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE)
     {
       parser_state &= ~PST_ENDALIAS;
@@ -2659,7 +2659,6 @@ pop_alias:
       if (uc)
        shell_input_line_index++;
     }
-#endif /* ALIAS || DPAREN_ARITHMETIC */
 
   if MBTEST(uc == '\\' && remove_quoted_newline && shell_input_line[shell_input_line_index] == '\n')
     {
@@ -3867,6 +3866,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
                    }
                  retind -= 2;          /* back up before the $' */
                }
+#if defined (TRANSLATABLE_STRINGS)
              else if MBTEST((tflags & LEX_WASDOL) && ch == '"' && (extended_quote || (rflags & P_DQUOTE) == 0))
                {
                  /* Locale expand $"..." here. */
@@ -3894,6 +3894,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
                  nestlen = strlen (nestret);
                  retind -= 2;          /* back up before the $" */
                }
+#endif /* TRANSLATABLE_STRINGS */
 
              APPEND_NESTRET ();
              FREE (nestret);
@@ -4938,7 +4939,11 @@ read_token_word (character)
              goto next_character;
            }
          /* This handles $'...' and $"..." new-style quoted strings. */
+#if defined (TRANSLATABLE_STRINGS)
          else if MBTEST(character == '$' && (peek_char == '\'' || peek_char == '"'))
+#else
+         else if MBTEST(character == '$' && peek_char == '\'')
+#endif
            {
              int first_line;
 
@@ -4964,6 +4969,7 @@ read_token_word (character)
                  ttranslen = strlen (ttok);
                  ttrans = ttok;
                }
+#if defined (TRANSLATABLE_STRINGS)
              else
                {
                  /* PST_NOEXPAND */
@@ -4983,6 +4989,7 @@ read_token_word (character)
                  ttrans = ttok;
                  ttranslen = strlen (ttrans);
                }
+#endif /* TRANSLATABLE_STRINGS */
 
              RESIZE_MALLOCED_BUFFER (token, token_index, ttranslen + 1,
                                      token_buffer_size,
diff --git a/shell.c b/shell.c
index ae1c61090ce71b1b7e17c7b10571f01c3fee45b5..c91efdaadab3729a27e71653ead07994435d6eb1 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -222,8 +222,10 @@ int no_line_editing = 0;   /* non-zero -> don't do fancy line editing. */
 #else
 int no_line_editing = 1;       /* can't have line editing without readline */
 #endif
+#if defined (TRANSLATABLE_STRINGS)
 int dump_translatable_strings; /* Dump strings in $"...", don't execute. */
 int dump_po_strings;           /* Dump strings in $"..." in po format */
+#endif
 int wordexp_only = 0;          /* Do word expansion only */
 int protected_mode = 0;                /* No command substitution with --wordexp */
 
@@ -248,8 +250,10 @@ static const struct {
 #if defined (DEBUGGER)
   { "debugger", Int, &debugging_mode, (char **)0x0 },
 #endif
+#if defined (TRANSLATABLE_STRINGS)
   { "dump-po-strings", Int, &dump_po_strings, (char **)0x0 },
   { "dump-strings", Int, &dump_translatable_strings, (char **)0x0 },
+#endif
   { "help", Int, &want_initial_help, (char **)0x0 },
   { "init-file", Charp, (int *)0x0, &bashrc_file },
   { "login", Int, &make_login_shell, (char **)0x0 },
@@ -498,11 +502,13 @@ main (argc, argv, env)
 
   set_login_shell ("login_shell", login_shell != 0);
 
+#if defined (TRANSLATABLE_STRINGS)
   if (dump_po_strings)
     dump_translatable_strings = 1;
 
   if (dump_translatable_strings)
     read_but_dont_execute = 1;
+#endif
 
   if (running_setuid && privileged_mode == 0)
     disable_priv_mode ();
@@ -955,7 +961,9 @@ parse_shell_options (argv, arg_start, arg_end)
              break;
 
            case 'D':
+#if defined (TRANSLATABLE_STRINGS)
              dump_translatable_strings = 1;
+#endif
              break;
 
            default:
diff --git a/subst.c b/subst.c
index e59e7a77625a9bd0a7e078810d94716147b3e0db..139346cddddb08e1c15b6f933179cd9eab11f3fd 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -3802,7 +3802,11 @@ expand_string_dollar_quote (string, flags)
 
        case '$':
          peekc = string[++sindex];
+#if defined (TRANSLATABLE_STRINGS)
          if (peekc != '\'' && peekc != '"')
+#else
+         if (peekc != '\'')
+#endif
            {
              RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 16);
              ret[retind++] = c;
@@ -3818,6 +3822,7 @@ expand_string_dollar_quote (string, flags)
              t = sh_single_quote (trans);
              sindex = news;
            }
+#if defined (TRANSLATABLE_STRINGS)
          else
            {
              news = ++sindex;
@@ -3831,6 +3836,7 @@ expand_string_dollar_quote (string, flags)
                t = sh_mkdoublequoted (trans, translen, 0);
              sindex = news;
            }
+#endif /* TRANSLATABLE_STRINGS */
          free (trans);
          trans = t;
          translen = strlen (trans);
diff --git a/tests/200 b/tests/200
new file mode 100644 (file)
index 0000000..e69de29
index cc8acb0cfe3646233dcafe3be185f604011973df..49b2bfe9c62bd19fb66f19c6b7814ad3a9b4dfc5 100644 (file)
@@ -15,10 +15,10 @@ set -- -a bb
 readonly OPTARG
 getopts :x x
 
-echo OPTARG = $OPTARG x = $x
+echo OPTARG = $OPTARG x = "$x"
 
 getopts x x
-echo ${OPTARG-unset} x = $x
+echo ${OPTARG-unset} x = "$x"
 
 typeset -r RO=foo
 typeset -n OPTARG=RO
index ade30b152fa11bb1828114d6e64a98760a4c07ce..0c3a2e5fb1a05cc4d3135a23c5092a6bd1e7ee80 100644 (file)
@@ -58,8 +58,8 @@ do
        run-ifs-tests|run-input-test|run-invert|run-more-exp|run-nquote) echo $x ; sh $x ;;
        run-ifs-posix|run-posix2|run-posixpat|run-posixpipe) echo $x ; sh $x ;;
        run-precedence|run-quote|run-read|run-rhs-exp|run-strip|run-tilde) echo $x ; sh $x ;;
-       run-dynvar) echo $x ; sh $x ;;
-       ;;
+       run-dynvar|run-iquote) echo $x ; sh $x ;;
+       run-type|run-comsub-eof|run-comsub-posix) echo $x ; sh $x ;;
        *)      ;;
        esac
        rm -f "$BASH_TSTOUT"