0

For explaining I use Firefox, but it also happens with other applications, here's the script:

$ cat ff.sh
#!/bin/sh
firefox http://superuser.com/
echo "$?"

Let's say Firefox is closed, when I run

$ ./ff.sh

the script is blocked until I close Firefox. Only after that I get the exit code.

0

$ 

Now let's say Firefox is already running, when I run the script it opens a new Firefox tab and runs through to the end. (And Firefox keeps running.)

$ ./ff.sh
0

$ 

How can I achieve that the behaviour is the same as in the first example regardless of the start condition? Basically I want to achieve the opposite of

$ cmd &
816-8055
  • 1,327

1 Answers1

0

It looks as if it ran asynchronously while in fact it did not.
When firefox launches it checks for existing instance, if found it delegates control to existing instance and ends itself. Hence the confusion.

guest
  • 3,419