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

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



Reply to message «Re: `jobs' builtin does not work with pipe in scripts», 
sent 20:47:39 26 November 2010, Friday
by Bart Schaefer:

What is your version of zsh? It does not work for me:
    (zyx:~) % zsh -fc 'sleep 3 & fg'
    zsh:fg:1: no job control in this shell.
    (zyx:~) % zsh -omonitor -fc 'sleep 3 & fg'
    zsh:fg:1: no job control in this shell.
    (zyx:~) % zsh -fc 'setopt monitor;sleep 3 & fg'
    zsh:setopt:1: can't change option: monitor
    zsh:fg:1: no job control in this shell.
And if zsh does not provide job control without this option, why `jobs' works as 
expected without pipe?

Original message:
> 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
> %

Attachment: signature.asc
Description: This is a digitally signed message part.



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