minimal-config changes; $"..." support is now a configuration option

This commit is contained in:
Chet Ramey
2021-12-01 16:40:52 -05:00
parent fffe80d438
commit 006856edf6
19 changed files with 136 additions and 26 deletions
+34
View 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
+2
View 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)
{
+2
View 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);
}
+3
View File
@@ -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. */
Vendored
+16 -1
View File
@@ -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
+7 -1
View 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)
+13 -9
View 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 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
+4
View 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}.
+1 -1
View 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
+17
View 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> */
+1 -1
View 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 */
+1 -1
View 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 *
+2
View File
@@ -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. */
+15 -8
View File
@@ -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,
+8
View File
@@ -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:
+6
View File
@@ -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);
View File
+2 -2
View 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
+2 -2
View 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"