Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: detect pipe



On 2021-01-28 12:58 p.m., Bart Schaefer wrote:

Speaking of that, what OS are you using?
Debian stable.
#alias g='tabs -4; noglob _g'
That is guaranteed NOT to work.  With that alias in place, your pipe
is feeding into the "tabs" command, and then the _g function is run
with the regular shell standard input in place.  Aliases are
command-text-level replacements, so  given the above,
Nuts, that makes sense.  Thing is tho that it usually did work, so maybe the puzzle is why it *ever* worked.   Running exactly the same command I'd get 'hit hit hit miss miss' that sort of thing.  But memory tickles me.  Something about sourcing a file and then the alias only works on the next call ... something like that? But I followed the wrong scent there, I removed it in the thought of speeding things up but your explanation is rock solid at least in theory.  Another one of my wild goose chases.  Tidbit: when I try 'tabs; noglob _g' it works.  The tab command fails for lack of an argument  and it seems the pipe then goes to '_g':


$ . test; echo "Now is the time for all good men" | test2 'the time'
PIPES ARE AS BAD AS CIGARETTES
Now is the time for all good men

$ . test; echo "Now is the time for all good men" | test2 'the time'
tabs: no tab-list given
NO, THEY AREN'T
grep: : No such file or directory






Messages sorted by: Reverse Date, Date, Thread, Author