Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: background command within function
On Tue, Dec 17, 2024, at 8:54 PM, Ray Andrews wrote:
> gg()
> {
> imwheel
> /opt/GeoGebra-Linux-Portable-5-2-853-0/geogebra-portable $@ &
> imwheel -k -q
> }
>
> ... I like to background things where I can, but in this case the
> function continues to execute and 'imwheel -k -q' gets run even before
> geogebra is quit.
Yes, that is how asynchronous lists work.
When a sublist is terminated by `;' or newline, the shell
waits for it to finish before executing the next sublist.
If a sublist is terminated by a `&', `&|', or `&!', the
shell executes the last pipeline in it in the background,
and does not wait for it to finish (note the difference
from other shells which execute the whole sublist in the
background). A backgrounded pipeline returns a status of
zero.
https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines
> I think I'm wanting to have my cake and eat it too,
> but just in case, can I have both? -- I get my prompt back, but the
> final command is not run until I quit geogebra?
Have the function run its commands synchronously, but invoke the
function itself asynchronously.
% gg() { imwheel; geogebra-portable "$@"; imwheel -k -q }
% gg &
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author