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

Re: `jobs' builtin does not work with pipe in scripts



On Nov 26,  7:38am, ZyX wrote:
}
} What more? `jobs -p | ...' is not working

If you want "jobs" to do something reliable, you have to set the
MONITOR option.  Zsh by default does not provide job control in a
non-interactive shell.

% zsh -fc 'sleep 3 & fg'
zsh:fg:1: no job control in this shell.
% zsh -fc 'setopt monitor; sleep 3 & fg'
[1] 25945
[1]  + running    sleep 3
% zsh -fc 'sleep 3 & jobs -p | sed s/run/RUN/'
% zsh -o monitor -fc 'sleep 3 & jobs -p | s/run/RUN/'
[1] 25967
[1]  + 25967 RUNning    sleep 3
% 



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