nullglob is documented incorrectly

2023-11-05 Thread Emanuele Torre
Today, a user in the #bash IRC channel of libera.chat, misunderstood how
nullglob is supposed to work because is documented incorrectly in the
man page:

'nullglob'
 If set, Bash allows filename patterns which match no files to
 expand to a null string, rather than themselves.

globs expand to nothing if there are no matches with nullglob set, not
to the null/empty string.

o/
 emanuele6



Re: nullglob is documented incorrectly

2023-11-05 Thread Andreas Kähäri
On Sun, Nov 05, 2023 at 11:15:50AM +0100, Emanuele Torre wrote:
> Today, a user in the #bash IRC channel of libera.chat, misunderstood how
> nullglob is supposed to work because is documented incorrectly in the
> man page:
> 
> 'nullglob'
>  If set, Bash allows filename patterns which match no files to
>  expand to a null string, rather than themselves.
> 
> globs expand to nothing if there are no matches with nullglob set, not
> to the null/empty string.
> 
> o/
>  emanuele6

It may even be better to say that the patterns that do not match
any names are *removed*.  That way one avoids the complications and
ambiguities of explaining what the pattern expands or not expands to.


-- 
Andreas (Kusalananda) Kähäri
Uppsala, Sweden

.



[PATCH] fdflags: fix -s with multiple flags, and multiple fd arguments

2023-11-05 Thread Emanuele Torre
fdflags -s  was re-parsing the setspec for each fd argument.
This is problematic because it is using  strtok()  to parse it
destructively.
So, only the first part of the setspec will be set for all file
descriptors; the other parts will only be set for the first file
descriptor:

  $ enable fdflags
  $ exec {foo1} /dev/null
  $ fdflags -- "$foo1" "$foo2"
  10:nonblock,cloexec
  11:nonblock
  $ exec {foo1}<&- {foo2}<&- {foo3}next)
 {
@@ -335,7 +336,7 @@ fdflags_builtin (WORD_LIST *list)
}
   num = inum;  /* truncate to int */
   if (setflag)
-   setone (num, setspec, verbose);
+   setone (num, setpos, setneg, verbose);
   else
printone (num, 1, verbose);
 }
-- 
2.42.0