Re: Setting nullglob causes variables containing backslashes to be expanded to an empty string

2019-08-07 Thread Chet Ramey
On 8/6/19 2:18 PM, Mohamed Akram wrote:
> Bash version: GNU bash, version 5.0.7(1)-release (x86_64-apple-darwin18.5.0)
> 
> Example:
> 
> shopt -s nullglob
> a='\x30'
> echo $a
> 
> Expected output:
> 
> \x30
> 
> Actual output:

Yes. Bash-5.0 changed so that backslashes in patterns are special
characters. This is what POSIX requires. There's more of an explanation
here:

https://lists.gnu.org/archive/html/bug-bash/2019-02/msg00151.html

So if patterns containing backslashes are patterns to be expanded (e.g.,
if the pattern is \x30 and there is a file named `x30' in the current
directory, the pattern should expand to `x30'), a failed pattern expansion
should be subject to the nullglob setting.

There is currently a ferocious -- well, it's mostly died down, but still
going on -- discussion on the POSIX mailing list about what POSIX *should*
say, but the current bash behavior is more-or-less -- POSIX doesn't have a
`nullglob' option -- what the POSIX shell group says should happen. I
assume there will be an interpretation for

http://austingroupbugs.net/view.php?id=1234

and I'll change bash to align with it.

Chet
-- 
``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: Async processes started in functions not reliably started

2019-08-07 Thread Steffen Nurpmeso
Hello.

Steffen Nurpmeso wrote in <20190806142527.9hs0i%stef...@sdaoden.eu>:
 |Robert Elz wrote in <26245.1565045...@jinx.noi.kre.to>:
 ||Date:Mon, 05 Aug 2019 14:05:43 +0200
 ||From:Steffen Nurpmeso 
 ||Message-ID:  <20190805120543.bf9-u%stef...@sdaoden.eu>
 ..
 ||The shell cannot really know - your example was not functional until
 ||after it set up the traps.
 ..
 ||In the parent:
 ||
 || OK=false
 || T=$(trap -p USR2)# only needed if USR2 might be trapped \
 || already
 || trap 'OK=true' USR2
 ...
 ||In the child:
 ||
 || trap 'whatever' SIG_I_NEED
 || # any other init that is needed
 ||
 || kill -s USR2 $$  # or if the parent pid is not $$, use whatever is.
 ...
 ||No temp files, named pipes, or othe similar stateful mechanisms needed.

Sorry for all that noise once again, but i have then rewritten it
using mkfifo etc. with credits for some of you (which collects
things i have seen flying by since Saturday night):

They also came up with the solution: do not wait(1) on child
processes until we know about their state, so that anytime before we
actually do wait(1) we can safely kill(1) them (Jilles Tjoelker).
Thus, let's create a FIFO (Chet Ramey) to get a synchronized
device, strip the wild test undertaker to a core that only writes
"timeout" to that FIFO, and also improve its startup-is-completed to
simply send a signal to the parent process (Robert Elz).  So
either the tests finish nicely, in which case they write their job
number to the fifo, or we see "timeout" and kill all remains.
There is still a minimal race which would falsely report tests as
failures, but should do no other harm.

Thanks.

--steffen
|
|Der Kragenbaer,The moon bear,
|der holt sich munter   he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)