nullglob make unset on array member fail ?
$ x=(x); echo ${#x[@]}; shopt -s nullglob; unset x[0]; echo ${#x[@]} 1 1 $ x=(x); echo ${#x[@]}; shopt -u nullglob; unset x[0]; echo ${#x[@]} 1 0
Re: nullglob make unset on array member fail ?
On Mon, Jan 23, 2017 at 03:04:40PM +0100, admn ombres wrote: > $ x=(x); echo ${#x[@]}; shopt -s nullglob; unset x[0]; echo ${#x[@]} You need to quote 'x[0]' to avoid having it globbed against files in the current working directory, regardless of whether you're using nullglob. The presence of a file named x0 in $PWD would change the meaning of your unset command from unset 'x[0]' to unset 'x0'.
Re: nullglob make unset on array member fail ?
On 1/23/17 9:04 AM, admn ombres wrote: > $ x=(x); echo ${#x[@]}; shopt -s nullglob; unset x[0]; echo ${#x[@]} > 1 > 1 > $ x=(x); echo ${#x[@]}; shopt -u nullglob; unset x[0]; echo ${#x[@]} > 1 > 0 `unset' is a builtin; its arguments are subject to all the shell word expansions, including globbing. If you don't want to take a chance on the effects of globbing modifying the word, quote it. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: read() may fail due to nonblocking stdin
On 1/22/17 2:32 PM, Siteshwar Vashisht wrote: > If a child process sets stdin to non-blocking and does not set it back to > blocking before exiting, other processes may fail to read from stdin. It's not the shell's business to be resetting this for processes it spawns. What bash should do is to turn of O_NONBLOCK when it reads input, which it already does at startup but not every time it calls readline(). Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: read() may fail due to nonblocking stdin
On 1/23/17 10:42 AM, Chet Ramey wrote: > On 1/22/17 2:32 PM, Siteshwar Vashisht wrote: >> If a child process sets stdin to non-blocking and does not set it back to >> blocking before exiting, other processes may fail to read from stdin. > > It's not the shell's business to be resetting this for processes it spawns. > What bash should do is to turn of O_NONBLOCK when it reads input, which it > already does at startup but not every time it calls readline(). And maybe I should make the follow-up point explicit: that will fix this problem, too. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: read() may fail due to nonblocking stdin
On 1/23/17 10:45 AM, Chet Ramey wrote: > On 1/23/17 10:42 AM, Chet Ramey wrote: >> On 1/22/17 2:32 PM, Siteshwar Vashisht wrote: >>> If a child process sets stdin to non-blocking and does not set it back to >>> blocking before exiting, other processes may fail to read from stdin. >> >> It's not the shell's business to be resetting this for processes it spawns. >> What bash should do is to turn of O_NONBLOCK when it reads input, which it >> already does at startup but not every time it calls readline(). > > And maybe I should make the follow-up point explicit: that will fix this > problem, too. Something like this, for instance. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/ *** ../bash-4.4-patched/parse.y 2016-09-11 11:31:46.0 -0400 --- parse.y 2017-01-23 13:54:53.0 -0500 *** *** 1454,1457 --- 1454,1458 } + sh_unset_nodelay_mode (fileno (rl_instream)); /* just in case */ current_readline_line = readline (current_readline_prompt ? current_readline_prompt : "");
null pointer deref, segfault
Going through some ancient bug reports and I came across https://savannah.gnu.org/support/index.php?108884 which apparently nobody uses anymore. <<$(()())|>_[$($(<<0)) crashes bash on Debian, Red Hat, FreeBSD, etc. Regards, Brian 'geeknik' Carpenter https://twitter.com/geeknik