summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2021-12-01 16:40:52 -0500
committerChet Ramey <chet.ramey@case.edu>2021-12-01 16:40:52 -0500
commit006856edf64d12b332058cf663901596327e7c0e (patch)
tree7faa3593231a5f2e3035c693097968e08a4423dd
parentfffe80d438966ab089444c13f61a06c6d325449c (diff)
downloadbash-006856edf64d12b332058cf663901596327e7c0e.tar.gz
minimal-config changes; $"..." support is now a configuration option
-rw-r--r--CWRU/CWRU.chlog34
-rw-r--r--builtins/set.def2
-rw-r--r--builtins/wait.def2
-rw-r--r--config.h.in3
-rwxr-xr-xconfigure17
-rw-r--r--configure.ac8
-rw-r--r--doc/bashref.info22
-rw-r--r--doc/bashref.texi4
-rw-r--r--examples/loadables/getconf.c2
-rw-r--r--examples/loadables/getconf.h17
-rw-r--r--examples/loadables/sleep.c2
-rw-r--r--lib/sh/shquote.c2
-rw-r--r--locale.c2
-rw-r--r--parse.y23
-rw-r--r--shell.c8
-rw-r--r--subst.c6
-rw-r--r--tests/2000
-rw-r--r--tests/getopts10.sub4
-rw-r--r--tests/run-minimal4
19 files changed, 136 insertions, 26 deletions
diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog
index f9476b20..cbe7d89d 100644
--- a/CWRU/CWRU.chlog
+++ b/CWRU/CWRU.chlog
@@ -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
diff --git a/builtins/set.def b/builtins/set.def
index a50764b6..44f17691 100644
--- a/builtins/set.def
+++ b/builtins/set.def
@@ -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)
{
diff --git a/builtins/wait.def b/builtins/wait.def
index 26578a4d..b4758404 100644
--- a/builtins/wait.def
+++ b/builtins/wait.def
@@ -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);
}
diff --git a/config.h.in b/config.h.in
index a0bfa9eb..d6d52930 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1161,6 +1161,9 @@
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. */
diff --git a/configure b/configure
index 0545990c..d2654f78 100755
--- 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 :
@@ -3823,6 +3834,10 @@ 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
printf "%s\n" "#define MEMSCRAMBLE 1" >>confdefs.h
diff --git a/configure.ac b/configure.ac
index 53f41a24..801b324d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
diff --git a/doc/bashref.info b/doc/bashref.info
index d0af3c40..8523de79 100644
--- a/doc/bashref.info
+++ b/doc/bashref.info
@@ -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 Type448568
Node: Sharing Defaults449284
Node: Operation Controls449957
Node: Optional Features450915
-Node: Reporting Bugs462008
-Node: Major Differences From The Bourne Shell463283
-Node: GNU Free Documentation License480133
-Node: Indexes505310
-Node: Builtin Index505764
-Node: Reserved Word Index512591
-Node: Variable Index515039
-Node: Function Index531531
-Node: Concept Index545315
+Node: Reporting Bugs462133
+Node: Major Differences From The Bourne Shell463408
+Node: GNU Free Documentation License480258
+Node: Indexes505435
+Node: Builtin Index505889
+Node: Reserved Word Index512716
+Node: Variable Index515164
+Node: Function Index531656
+Node: Concept Index545440

End Tag Table
diff --git a/doc/bashref.texi b/doc/bashref.texi
index 02a2992e..bd45aa55 100644
--- a/doc/bashref.texi
+++ b/doc/bashref.texi
@@ -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}.
diff --git a/examples/loadables/getconf.c b/examples/loadables/getconf.c
index 82f80bb2..8ca13ca5 100644
--- a/examples/loadables/getconf.c
+++ b/examples/loadables/getconf.c
@@ -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
diff --git a/examples/loadables/getconf.h b/examples/loadables/getconf.h
index ed4bbb94..b8b9f102 100644
--- a/examples/loadables/getconf.h
+++ b/examples/loadables/getconf.h
@@ -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> */
diff --git a/examples/loadables/sleep.c b/examples/loadables/sleep.c
index 32055ac1..204601f5 100644
--- a/examples/loadables/sleep.c
+++ b/examples/loadables/sleep.c
@@ -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 */
diff --git a/lib/sh/shquote.c b/lib/sh/shquote.c
index 680f84ed..55310ce4 100644
--- a/lib/sh/shquote.c
+++ b/lib/sh/shquote.c
@@ -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 *
diff --git a/locale.c b/locale.c
index 8d13910d..fabf7b12 100644
--- 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 6e1770ab..990fcc46 100644
--- 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 ae1c6109..c91efdaa 100644
--- 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 e59e7a77..139346cd 100644
--- 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
index 00000000..e69de29b
--- /dev/null
+++ b/tests/200
diff --git a/tests/getopts10.sub b/tests/getopts10.sub
index cc8acb0c..49b2bfe9 100644
--- a/tests/getopts10.sub
+++ b/tests/getopts10.sub
@@ -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
diff --git a/tests/run-minimal b/tests/run-minimal
index ade30b15..0c3a2e5f 100644
--- a/tests/run-minimal
+++ b/tests/run-minimal
@@ -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"