You are not logged in.

#1 2010-03-08 14:51:36

ammon
Member
Registered: 2008-12-11
Posts: 413

Bash wait command

Hi, im trying to make zsh alias to kill xcompmgr before nexuiz starts, and start it again when it finishes. How to do that?

alias nexuiz="killall xcompmgr ; nexuiz-sdl-svn ; wait $PID ; xcompmgr -CfFn -D 5 &"

Something is wrong with wait command? What option should I use?

Offline

#2 2010-03-08 14:55:45

milomouse
Member
Registered: 2009-03-24
Posts: 940
Website

Re: Bash wait command

if you're using an alias, AFAIK, you could use "&&" instead of ";"
&& waits for first command to finish and goes to the next one, so "killall xcompgr && nexuiz-sdl-svn .." will kill xcompgr first, then execute nexuiz-sdl-svn, etc

i think this will work, unless i read your post wrong

Last edited by milomouse (2010-03-08 14:56:27)

Offline

#3 2010-03-08 15:16:52

JohannesSM64
Member
From: Norway
Registered: 2009-10-11
Posts: 623
Website

Re: Bash wait command

No, the difference between ; and && is that && only goes on if the preceding commands succeeds (exit code 0).
Unless your setup somehow automatically manages the $PID environment variable, it's probably empty, and will expand to nothing, and the wait command will have the same effect as running 'wait' without arguments. From what I can tell from the man page, if 'wait' is invoked with no arguments, it will wait until all process IDs known to the invoking shell have terminated, which is not what you want.

Offline

#4 2010-03-08 15:18:39

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: Bash wait command

Launch nex into another display instead of screwing with the current one.

Offline

#5 2010-03-08 15:25:40

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Bash wait command

alias nexuiz="killall xcompmgr; nexuiz-sdl-svn && xcompmgr -CfFn -D 5 &"

The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#6 2010-03-08 15:58:06

ammon
Member
Registered: 2008-12-11
Posts: 413

Re: Bash wait command

moljac024 wrote:
alias nexuiz="killall xcompmgr; nexuiz-sdl-svn && xcompmgr -CfFn -D 5 &"

Ty, that does it.

Offline

#7 2010-03-09 04:24:41

JohannesSM64
Member
From: Norway
Registered: 2009-10-11
Posts: 623
Website

Re: Bash wait command

Yes, but that will only start xcompmgr again if nexuiz exits successfully, not if it crashes. Use ;

Last edited by JohannesSM64 (2010-03-09 04:25:57)

Offline

#8 2010-03-09 05:17:07

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,410
Website

Re: Bash wait command

Not an answer, but why not just create a launcher script and put it somewhere in your path?  Or even, make it a function in your ~/.bashrc

Offline

Board footer

Powered by FluxBB