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

Re: disown -a



zzapper wrote on Tue, 02 Mar 2021 23:31 +00:00:
> Confused as to whether disown behaves differently between zsh & bash
> 

Presumably you mean "why" rather than "whether".  About that, see
https://github.com/zsh-users/zsh/blob/5ede2c55f144593c16498c3131a76e188114a9c6/Etc/FAQ.yo#L2056-L2102,
the first and penultimate paragraphs.

More below.

> in zsh
> 
>  >disown -a
> disown: job not found: -a
> 
> 
>   bash
> 
> david@mint-HP-600B  $ sleep 200
> ^Z
> [1]+  Stopped                 sleep 200
> david@mint-HP-600B  $ disown -a
> bash: warning: deleting stopped job 1 with process group 47533
> 
> 
> I desire to use disown -a in zsh but it's not working and not documented

zsh is not a bug-for-bug reimplementation of bash.

As to a workaround, you don't specify what -a should do, but perhaps this:

disown %${(k)^jobstates[(R)suspended:*]}

The references for that are spread across several parts of the manual
(zshexpn(1) for ${^foo}, zshmodules(1) for $jobstates, etc), but in a
nutshell, it disowns the jobs that are listed as "suspended" in
$jobstates.

You can even syntactic sugar that:

function disown() {
  if [[ $# -eq 1 && #1 == -a ]] ; then set -- %${(k)^jobstates[(R)suspended:*]} ; fi
  builtin disown "$@"
}




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