I'm writing a script that launches a virtual framebuffer with Xvfb. I want to make sure the command succeeds, but I don't want the script to wait until the command completes, because Xvfb continues running until the X server is killed. For example:
if ! Xvfb $DISPLAY &; then
echo 'Error: failed to create virtual frame buffer'
exit 1
fi
xpid=$!
# do stuff that uses frame buffer
kill $xpid
The problem with this is it throws a syntax error on &;:
$ stuff.sh
stuff.sh: line 149: syntax error near unexpected token `;'
stuff.sh: line 149: `if ! Xvfb $DISPLAY &; then'
I tried changing that line to if ! Xvfb $DISPLAY & ; but it still throws the error.