Re: doesn't bash do variable subst. or quote removal on function statement
Linda Walshwrites: >> shopt -s expand_aliases; alias my=declare >> declare fn=myfunc## function name in variable > doesn't work >> function $fn { echo $fn ; } > -bash: `$fn': not a valid identifier >>my -pf myfunc > -bash: declare: myfunc: not found >> >> def="function $fn () { echo $fn ; }" ## but same statement, eval'd works That's not the same statement. The same statement would be def='function $fn () { echo $fn ; }' Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
implicit redirection of background within pipeline
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall uname output: Linux treehug.home.kurahaupo.gen.nz 3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:27:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 4.3 Patch Level: 11 Release Status: release Description: The first backgrounded element within a pipeline component has its stdin redirected to /dev/null; this does not apply to the second and subsequent background elements. On a Linux system this can be observed with: echo x | ( ls -ld /proc/self/fd/0 & ls -ld /proc/self/fd/0 & wait ) On other systems it is apparent simply with: echo x | ( cat & wait ) # no output is produced Repeat-By: # this command produces no output: echo x | ( cat & wait ) Fix: # this is only a work-around: echo x ( :& cat & wait )
"read < <(:); echo $?" prints 0 when job control is disabled (should be 1?)
When job control is enabled: $ read < <(:); echo $? 1 When job control is disabled: $ read < <(:); echo $? 0 Is this a bug, or valid behavior? It seems to be caused by already_making_children being set in the bash without job control; the shell waits for a child and sets exec_status to 0 (the read builtin returns 1). I've reproduced this on both an x86_64 machine and in a MIPS VM, with both bash 4.3.42, and bash 4.4.0 (ie devel). Note that (with job control disabled) $ : | read; echo $? 1 and $ false < <(:); echo $? 0 or, $ false <(:); echo $? 0 while $ false; echo $? 1 (using a process substitution seems to trigger the behavior) Alastair Hughes
Re: implicit redirection of background within pipeline
hey, I am quite sure it happens here (devel branch, at 6f82653c5ef09aeeeba4376a1c65ce86c3605c00): execute_cmd.c +5115: if ((cmdflags & CMD_STDIN_REDIR) && pipe_in == NO_PIPE && (stdin_redirects (redirects) == 0)) async_redirect_stdin (); but after reading the comments some 3.5k lines earlier I am not sure how to fix it; of course commenting out the if in execute_cmd.c:5112-5115 solves it, but who can tell what it breaks? cheers, pg On Sun, Jan 10, 2016 at 8:23 AM, Martin D Kealeywrote: > > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' > -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL > -DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -D_FORTIFY_SOURCE=2 > -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat > -Werror=format-security -Wall > uname output: Linux treehug.home.kurahaupo.gen.nz 3.13.0-55-generic > #94-Ubuntu SMP Thu Jun 18 00:27:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux > Machine Type: x86_64-pc-linux-gnu > > Bash Version: 4.3 > Patch Level: 11 > Release Status: release > > Description: > The first backgrounded element within a pipeline component has its > stdin redirected to /dev/null; this does not apply to the second and > subsequent background elements. > > On a Linux system this can be observed with: > echo x | ( ls -ld /proc/self/fd/0 & >ls -ld /proc/self/fd/0 & >wait ) > > On other systems it is apparent simply with: > echo x | ( cat & wait ) > # no output is produced > > Repeat-By: > # this command produces no output: > echo x | ( cat & wait ) > > Fix: > # this is only a work-around: > echo x ( :& cat & wait ) > >