return bultin ignores explicit exit value when used in DEBUG trap

2015-11-18 Thread Grisha Levit
Not sure if this is a documentation bug or a functional one, but the man page does not seem to agree with the observed behavior for return when invoked in DEBUG traps. return [n] Causes a function to stop executing and return the value specified by n to its caller. If n is omitted, the re

Re: Proposed Prompt Escapes

2015-11-18 Thread isabella parakiss
On 11/19/15, Ángel González wrote: > Dennis Williamson wrote: >> Do you mean something like: >> >> PS1='$SECONDS ' > > Not exactly. $SECONDS is the number of seconds since the shell was > started. I am interested in the seconds elapsed by the last command. > > It is a hacky solution, but it could

Re: Proposed Prompt Escapes

2015-11-18 Thread Ángel González
Dennis Williamson wrote: > Do you mean something like: > > PS1='$SECONDS ' Not exactly. $SECONDS is the number of seconds since the shell was started. I am interested in the seconds elapsed by the last command. It is a hacky solution, but it could be done with: > PS1=''; PROMPT_COMMAND='printf "

Re: redirecting a file descriptor to an array variable? Possible? How? RFE?

2015-11-18 Thread Greg Wooledge
On Wed, Nov 18, 2015 at 12:29:15PM -0800, Linda Walsh wrote: > Greg Wooledge wrote: > >An argument cannot contain a NUL byte. So it's moot. > --- > As in: > >printf '"%c"\n' $'\x00'|hexdump -C > 22 00 22 0a |".".| imadev:~$ printf '"%c"\n' ''

Re: redirecting a file descriptor to an array variable? Possible? How? RFE?

2015-11-18 Thread Linda Walsh
Greg Wooledge wrote: On Wed, Nov 18, 2015 at 10:46:57AM -0800, Linda Walsh wrote: One thing that seems to be another problem. Greg called my attention to another printf format bug: %q causes printf to output the corresponding argument in a

OLDPWD unset when bash starts

2015-11-18 Thread John Wiersba
Why does bash clear OLDPWD when a child script is started? OLDPWD is exported and passed to any children, but bash apparently clears OLDPWD whenever a child script is started: $ cd /etc $ cd $ perl -e 'print "<$ENV{OLDPWD}>\n"' $ ksh -c 'echo "<$OLDPWD>"' $ bash -c 'echo "<$OLDPWD>"' <> $ un

Re: redirecting a file descriptor to an array variable? Possible? How? RFE?

2015-11-18 Thread Linda Walsh
Greg Wooledge wrote: You should stop using irrelevant examples, and return to your core question. I believe your initial goal was to run a command, and capture the command's stdout in one variable, and the command's stderr in another variable, without using any temp files. Actual

Re: redirecting a file descriptor to an array variable? Possible? How? RFE?

2015-11-18 Thread Greg Wooledge
On Wed, Nov 18, 2015 at 10:46:57AM -0800, Linda Walsh wrote: > One thing that seems to be another problem. Greg called > my attention to another printf format bug: > > %q causes printf to output the corresponding argument in > a > format

Re: redirecting a file descriptor to an array variable? Possible? How? RFE?

2015-11-18 Thread Greg Wooledge
On Wed, Nov 18, 2015 at 10:16:46AM -0800, Linda Walsh wrote: > So just like you can have [<>|]&[-0-9][0-0] as redirection ops that > work > with files or FD's, why not have something like: > > out=() > printf '%s\0' "${array[@]}" >&{out[@]} (**) > > **: or ">@out" or ">&@out" You se

Re: redirecting a file descriptor to an array variable? Possible? How? RFE?

2015-11-18 Thread Linda Walsh
konsolebox wrote: On Fri, Nov 13, 2015 at 8:45 AM, Linda Walsh wrote: I'd like to be able to record stdout and stderr without using any temp files into bash array files, AND record the status of the command executed. You can use coproc processes that would act as buffers. Obvious Note: Avo

Re: redirecting a file descriptor to an array variable? Possible? How? RFE?

2015-11-18 Thread Linda Walsh
Greg Wooledge wrote: On Sun, Nov 15, 2015 at 05:26:26AM -0800, Linda Walsh wrote: This can be used to serialize an array into a file and to read it back: printf '%s\0' "${array[@]}" > file So just like you can have [<>|]&[-0-9][0-0] as redirection ops that work with files or FD's