fixes to printf for wide characters in single-byte locales; fixes to job notification for -c command shells

This commit is contained in:
Chet Ramey
2024-03-13 09:33:32 -04:00
parent 54f3ed2278
commit bf944fe91f
9 changed files with 539 additions and 492 deletions
+30
View File
@@ -8777,3 +8777,33 @@ subst.c
- expand_word_internal: if CTLNUL is a IFS character, don't add quoted
null strings to istring if we're going to be word splitting, since
they will be treated as word delimiters
3/6
---
examples/loadables/getconf.c
- getconf_builtin,getconf_all: changes for POSIX interp 1808 proposal
to allow an optional pathname argument with -a that forces its use
for pathconf variables
https://www.austingroupbugs.net/view.php?id=1808
3/11
----
builtins/printf.def
- printf_builtin: %lc/%ls (%C/%S) should only work on wide characters
when in a locale where MB_CUR_MAX > 1.
Report by Emanuele Torre <torreemanuele6@gmail.com>
3/12
----
jobs.c
- notify_of_job_status: don't mark terminated background jobs or stopped
jobs as notified in shells started to run -c command
From a report by Greg Wooledge <greg@wooledge.org>
- notify_of_job_status: make the final marking the dead job as notified
a true catch-all so we can put a debugging message in there to see
if there are other missing cases
- notify_of_job_status: don't mark terminated jobs that died due to
a signal the shell trapped (on the assumption that the shell
received the signal, too) as notified, since we don't report on it
in the JDEAD case if the signal is trapped
+2 -2
View File
@@ -492,7 +492,7 @@ printf_builtin (WORD_LIST *list)
char p;
#if defined (HANDLE_MULTIBYTE)
if (longform || convch == 'C')
if ((longform || convch == 'C') && locale_mb_cur_max > 1)
{
wchar_t wc, ws[2];
int r;
@@ -522,7 +522,7 @@ printf_builtin (WORD_LIST *list)
{
char *p;
#if defined (HANDLE_MULTIBYTE)
if (longform || convch == 'S')
if ((longform || convch == 'S') && locale_mb_cur_max > 1)
{
wchar_t *wp;
size_t slen;
+18 -6
View File
@@ -941,7 +941,7 @@ static const struct conf vars[] =
};
static int getconf_print (const struct conf *, const char *, int);
static int getconf_all (void);
static int getconf_all (WORD_LIST *);
static int getconf_one (WORD_LIST *);
static int getconf_internal (const struct conf *, int);
@@ -1035,17 +1035,23 @@ getconf_internal (const struct conf *c, int all)
}
static int
getconf_all (void)
getconf_all (WORD_LIST *list)
{
const struct conf *c;
char *path;
int r;
r = EXECUTION_SUCCESS;
path = list ? list->word->word : 0;
for (c = vars; c->name != NULL; ++c)
{
if (c->call == PATHCONF && path == 0)
continue; /* Don't print pathconf vars if no path supplied */
#if 0
if (c->call != PATHCONF && path)
continue; /* Only print pathconf vars if path supplied */
#endif
printf("%-35s", c->name);
path = "/"; /* XXX for now */
if (getconf_print (c, path, 1) == EXECUTION_FAILURE)
r = EXECUTION_FAILURE;
}
@@ -1189,13 +1195,19 @@ getconf_builtin (WORD_LIST *list)
}
list = loptend;
if ((aflag == 0 && list == 0) || (aflag && list) || list_length((GENERIC_LIST *)list) > 2)
if ((aflag == 0 && list == 0) || (list && list_length((GENERIC_LIST *)list) > 2))
{
builtin_usage();
return (EX_USAGE);
}
else if (aflag && list && (list->word == 0 || list->word->word == 0 || *list->word->word == 0))
{
/* No null pathnames with -a */
builtin_usage();
return (EX_USAGE);
}
r = aflag ? getconf_all () : getconf_one (list);
r = aflag ? getconf_all (list) : getconf_one (list);
return r;
}
@@ -1212,6 +1224,6 @@ struct builtin getconf_struct = {
getconf_builtin,
BUILTIN_ENABLED,
getconf_doc,
"getconf -[ah] or getconf [-v spec] sysvar or getconf [-v spec] pathvar pathname",
"getconf -[ah] [file] or getconf [-v spec] sysvar or getconf [-v spec] pathvar pathname",
0
};
+16 -5
View File
@@ -4288,10 +4288,11 @@ notify_of_job_status (void)
if (startup_state == 0 && WIFSIGNALED (s) == 0 &&
((DEADJOB (job) && IS_FOREGROUND (job) == 0) || STOPPED (job)))
continue;
/* Do the same thing and don't print anything or mark as notified
for the signals we're not going to report on */
else if (startup_state == 0 && DEADJOB (job) && IS_FOREGROUND (job) == 0 &&
for the signals we're not going to report on. This is the opposite
of the first two cases under case JDEAD below. */
else if (interactive_shell == 0 && DEADJOB (job) && IS_FOREGROUND (job) == 0 &&
WIFSIGNALED (s) && (termsig == SIGINT
#if defined (DONT_REPORT_SIGTERM)
|| termsig == SIGTERM
@@ -4299,7 +4300,13 @@ notify_of_job_status (void)
#if defined (DONT_REPORT_SIGPIPE)
|| termsig == SIGPIPE
#endif
))
|| signal_is_trapped (termsig)))
continue;
/* hang onto the status if the shell is running -c command */
else if (startup_state == 2 && subshell_environment == 0 &&
WIFSIGNALED (s) == 0 &&
((DEADJOB (job) && IS_FOREGROUND (job) == 0) || STOPPED (job)))
continue;
/* If job control is disabled, don't print the status messages.
@@ -4376,7 +4383,11 @@ notify_of_job_status (void)
/* Interactive shells without job control enabled are handled
above. */
/* XXX - this is a catch-all in case we missed a state */
jobs[job]->flags |= J_NOTIFIED;
else
{
internal_debug("notify_of_job_status: catch-all setting J_NOTIFIED on job %d (%d), startup state = %d", job, jobs[job]->flags, startup_state);
jobs[job]->flags |= J_NOTIFIED;
}
break;
case JSTOPPED:
+1 -1
View File
@@ -25,7 +25,7 @@ static void *initialbrk;
static void *curbrk;
static int
brkinit (void)
initbrk (void)
{
if (initialbrk == 0)
{
BIN
View File
Binary file not shown.
+466 -472
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+6 -6
View File
@@ -1,15 +1,15 @@
# Messages français pour GNU concernant bash.
# Copyright (C) 2022 Free Software Foundation, Inc.
# Copyright (C) 2024 Free Software Foundation, Inc.
# This file is distributed under the same license as the bash package.
# Michel Robitaille <robitail@IRO.UMontreal.CA>, 2004
# Christophe Combelles <ccomb@free.fr>, 2008, 2009, 2010, 2011
# Frédéric Marchal <fmarchal@perso.be>, 2022
# Frédéric Marchal <fmarchal@perso.be>, 2024
msgid ""
msgstr ""
"Project-Id-Version: bash-5.2-rc1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-11 14:50-0500\n"
"PO-Revision-Date: 2022-06-19 10:44+0200\n"
"PO-Revision-Date: 2024-03-11 07:13+0100\n"
"Last-Translator: Frédéric Marchal <fmarchal@perso.be>\n"
"Language-Team: French <traduc@traduc.org>\n"
"Language: fr\n"
@@ -3219,7 +3219,7 @@ msgstr ""
" « getopts » est utilisé par les procédures du shell pour analyser les \n"
" paramètres de position.\n"
" \n"
" OPTSTRING contient les lettres d'options qui devront être reconnues ;\n"
" CHAÎNEOPTS contient les lettres d'options qui devront être reconnues ;\n"
" si une lettre est suivie par un deux-points, elle devra posséder un\n"
" argument séparé d'elle par une espace.\n"
" \n"
@@ -3231,7 +3231,7 @@ msgstr ""
" argument dans la variable de shell OPTARG.\n"
" \n"
" « getopts » signale les erreurs de deux manières. Si le premier caractère\n"
" d'OPTSTRING est un deux-points, « getopts » utilise un signalement d'erreur\n"
" de CHAÎNEOPTS est un deux-points, « getopts » utilise un signalement d'erreur\n"
" silencieux. Dans ce mode aucun message d'erreur n'est affiché. Si une option\n"
" incorrecte est rencontrée, « getopts » place dans OPTARG le caractère d'option\n"
" trouvé. Si un argument nécessaire n'est pas trouvé, « getopts » place un « : »\n"
@@ -3242,7 +3242,7 @@ msgstr ""
" diagnostic est affiché.\n"
" \n"
" Si la variable de shell OPTERR possède la valeur 0, « getopts » désactive\n"
" l'affichage des messages d'erreur, même si le premier caractère d'OPTSTRING\n"
" l'affichage des messages d'erreur, même si le premier caractère de CHAÎNEOPTS\n"
" n'est pas un deux-points. OPTERR possède la valeur 1 par défaut.\n"
" \n"
" « getopts » analyse habituellement les paramètres de position, mais si des arguments\n"