bash 1-liner or function to tee to STDERR in middle of pipe?

2020-07-03 Thread bug-bash
This does what I want: --8<---cut here---start->8--- _tee_stderr () { <<'eohd' SYNOPSIS ourname DESCRIPTION Use in a pipe. Leaks STDIN to STDERR. Passes STDIN to STDOUT unchanged. EXAMPLE $ seq 5 |_tee_stderr

Re: bash 1-liner or function to tee to STDERR in middle of pipe?

2020-07-03 Thread Lawrence Velázquez
> On Jul 3, 2020, at 10:32 AM, bug-b...@trodman.com wrote: > > This does what I want: > > --8<---cut here---start->8--- > _tee_stderr () > { > <<'eohd' >SYNOPSIS > >ourname > >DESCRIPTION > >Use in a pipe. Leaks STDIN to S

Return from function depending on number of parameters

2020-07-03 Thread Chris Elvidge
I've used 'return $((!$#))' and 'return $[!$#]' to return an error if no parameters given to function. Tested in a bash script 'exit $((!$#)) / $[!$#]' - both work. 'echo $((!$#)) / $[!$#]' - both echo 1 when no params, 0 when any number of params. I'm told ( https://wiki.bash-hackers.org/s

Re: Return from function depending on number of parameters

2020-07-03 Thread Lawrence Velázquez
> On Jul 3, 2020, at 2:00 PM, Chris Elvidge wrote: > > However 'N=0; echo $((!$N))' gives an error at the bash prompt. > 'echo $[!$N]' echo's 1 as expected. > > My question - is $[...] actually obsolete? It might tell you something that $[...] is not even mentioned in the man page for bash 3.2.

Re: Return from function depending on number of parameters

2020-07-03 Thread Eli Schwartz
On 7/3/20 2:00 PM, Chris Elvidge wrote: > I've used 'return $((!$#))' and 'return $[!$#]' to return an error if no > parameters given to function. > > Tested in a bash script 'exit $((!$#)) / $[!$#]' - both work. > > 'echo  $((!$#)) / $[!$#]' - both echo 1 when no params, 0 when any > number of p