Re: Rendering the Bash man page with commercial Unix/System V nroff
On 2/12/24 4:26 PM, G. Branden Robinson wrote: Hi Chet, At 2024-02-12T14:45:30-0500, Chet Ramey wrote: On 2/12/24 2:00 PM, G. Branden Robinson wrote: I see that most of my proposed man page changes from the recent series landed in the devel branch. Thanks! I did notice that this one and its follow-up did not. Was that on purpose? Is there something I can do to improve the patch? I just ran out of steam. Oh! That possibility had not occurred to me. :-O There are three man pages that need these updates, and I go over each change to make sure it's what's intended (e.g., sometimes double quote is part of the syntax being described and should be typeset one way, and sometimes it's just a double quote quoting something in a string and should be typeset a different way). This last set will be there in the next devel branch push. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: [PATCH] ASS_NOEVAL for BASHOPTS and SHELLOPTS
On 2/7/24 1:43 AM, Grisha Levit wrote: (Prompted by the report from Emanuele Torre in [1]) The value of currently_executing_command is garbage when there is an error during assignment when popping the variable context: $ bash -c 'declare -i SHELLOPTS; f() { local -; set -f; }; f' |& cat -v bash: line 1: M-`^WM-R^N^\{: braceexpand:hashall:interactive-comment... $ bash-asan -c 'declare -i SHELLOPTS; f() { local -; set -f; }; f' SUMMARY: AddressSanitizer: heap-use-after-free execute_cmd.c:399 in executing_line_number I fixed the underlying issue: assigning a variable to something you're going to unwind-protect without unwind-protecting the variable. I'm not sure that allowing the integer attribute to be changed really makes sense for readonly variables No one responded when I asked the question here: https://lists.gnu.org/archive/html/bug-bash/2024-01/msg00188.html -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: declare -A +A
On 2/12/24 5:24 PM, Koichi Murase wrote: 2024年2月13日(火) 6:13 Chet Ramey : Only for indexed and associative arrays, since those are the attributes that cause changes in the underlying value storage format. That's different than turning the integer attribute on and off, for instance. Should it be an actual error, or should the shell just cancel out the attribute change requests and go on? What do folks think? I think it can be a usage error; it doesn't do anything on the variable (i.e. doesn't make it an associative array) and outputs an error message. I agree; I'll make it a usage error. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: declare -Aa var
On 2/7/24 1:48 AM, Grisha Levit wrote: If given both the -a and -A flags and an existing scalar variable, declare will assign both attributes to the variable: $ V=X; declare -Aa V; echo $? 0 $ echo ${V@a} aA $ (declare -p V) Segmentation fault: 11 For the time being, we'll make this an error instead of `last one wins'. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: It is possible to remove the readonly attribute from {BASH, SHELL}OPTS
On Wed, Jan 31, 2024, 14:10 Chet Ramey wrote: > Well, is this a "my arm hurts when I do this" problem, or should bash > restrict the types of attributes that can be set on readonly variables? > For the attributes that only affect future assignments ([iluc]), I think think it makes sense to either (a) restrict the ability to change these attributes on readonly variables or (b) make internal assignments that force new values on readonly variables ignore such attributes. Option (a) makes the behavior more transparent to the user, but I can't say if the added complexity is worth it. My ASS_NOEVAL patch was meant as an attempt at option (b). If code were to be added to restrict adding the above attributes, then restricting [aA] might make sense too. While converting a readonly scalar variable to an array does have a user-visible consequence -- an exported scalar variable is no longer present in the environment after being converted to an array -- one can already toggle the export attribute of readonly variables. This leaves the trace attribute, which doesn't do anything for variables, but I've occasionally found it useful for debugging Bash issues so would put in a weak vote to not restrict its modification. >
[PATCH] Fix minor portability issues including ISO C 23 prototypes.
Hi, I noticed some compiler warnings that might be worth fixing. I wasn't sure if patches should have ChangeLog entries so I left it alone and tried to make it easy to copy paste for you. Feel free to use or ignore changes as you see fit. Thanks, Collin * lib/malloc/malloc.c (botch): Add correct prototype so declaration is compatible with C23. * lib/malloc/table.h (mregister_describe_mem): Add correct prototype so declaration is compatible with C23. * lib/sh/getenv.c (getenv, putenv, setenv, unsetenv): Don't assume that NULL is equivalent to 0 and just use the macro itself. * lib/sh/strlcpy.c (strlcpy): Remove duplicate const qualifier. diff from commit fbc7d97de6c6f3dedb34f49f89a628a99ef6ddf5 on devel: --- lib/malloc/malloc.c | 3 ++- lib/malloc/table.h | 2 +- lib/sh/getenv.c | 10 +- lib/sh/strlcpy.c| 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c index f829d395..9674f4d0 100644 --- a/lib/malloc/malloc.c +++ b/lib/malloc/malloc.c @@ -322,7 +322,8 @@ static PTR_T internal_valloc (size_t, const char *, int, int); static PTR_T internal_remap (PTR_T, size_t, int, int); #if defined (botch) -extern void botch (); +/* XXX - set to `programming_error' by Makefile. */ +extern void botch (const char *, ...); #else static void botch (const char *, const char *, int); #endif diff --git a/lib/malloc/table.h b/lib/malloc/table.h index e7803762..f8f74639 100644 --- a/lib/malloc/table.h +++ b/lib/malloc/table.h @@ -60,7 +60,7 @@ typedef struct mr_table { extern mr_table_t *mr_table_entry (PTR_T); extern void mregister_alloc (const char *, PTR_T, size_t, const char *, int); extern void mregister_free (PTR_T, int, const char *, int); -extern void mregister_describe_mem (); +extern void mregister_describe_mem (PTR_T, FILE *); extern void mregister_dump_table (void); extern void mregister_table_init (void); diff --git a/lib/sh/getenv.c b/lib/sh/getenv.c index 6917f075..f19d2c69 100644 --- a/lib/sh/getenv.c +++ b/lib/sh/getenv.c @@ -51,7 +51,7 @@ getenv (const char *name) { SHELL_VAR *var; - if (name == 0 || *name == '\0') + if (name == NULL || *name == '\0') return ((char *)NULL); var = find_tempenv_variable ((char *)name); @@ -103,7 +103,7 @@ putenv (char *str) char *name, *value; int offset; - if (str == 0 || *str == '\0') + if (str == NULL || *str == '\0') { errno = EINVAL; return -1; @@ -148,13 +148,13 @@ setenv (const char *name, const char *value, int rewrite) SHELL_VAR *var; char *v; - if (name == 0 || *name == '\0' || strchr (name, '=') != 0) + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) { errno = EINVAL; return -1; } - var = 0; + var = NULL; v = (char *)value; /* some compilers need explicit cast */ /* XXX - should we worry about readonly here? */ if (rewrite == 0) @@ -186,7 +186,7 @@ _setenv (const char *name, const char *value, int rewrite) int unsetenv (const char *name) { - if (name == 0 || *name == '\0' || strchr (name, '=') != 0) + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) { errno = EINVAL; return (-1); diff --git a/lib/sh/strlcpy.c b/lib/sh/strlcpy.c index 787e4c36..ae30c2ee 100644 --- a/lib/sh/strlcpy.c +++ b/lib/sh/strlcpy.c @@ -23,7 +23,7 @@ #include size_t -strlcpy(char *dest, const const char *src, size_t size) +strlcpy (char *dest, const char *src, size_t size) { size_t ret; -- 2.39.2