Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Aug 1998 10:06:55 -0700 (PDT)
From:      David Wolfskill <dhw@whistle.com>
To:        questions@FreeBSD.ORG, vagner@kf7nn.com
Subject:   Re: wait for last command
Message-ID:  <199808311706.KAA21737@pau-amma.whistle.com>
In-Reply-To: <199808310233.VAA04752@mutsgo.kf7nn.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>From: Laszlo Vagner <vagner@kf7nn.com>
>Date: Sun, 30 Aug 1998 21:33:52 -0500 (CDT)

>when writing a shell script that has say a few lines of executables
>to run does it spawn multiple processes at the same time to run them or
>does it run them one after the other.

Absent the trailing ampersand ("&"), the shell forks the command, then
waits for it to return, then processes the next line.

(That said, it's possible for the command in question to also fork other
processes, and whether or not all of them have terminated before the
process the shell forks terminates depends on how they are implemented.)

>so are they run sequentially and do they wait to complete before
>executing the next line ??

They wait.

>i have seen people put && after an executable what is it for?

That's normally done in a sequence, such as

	rm -fr foo && mkdir foo

which says "recursively remove foo (and everything in it, if it's a
directory); then, if that worked OK, create a (new) "foo" directory.

The "&&" is the "logical AND" operator, which is evaluated in a "short
circuit" form (as it is in C and Perl):  if the return from the first
command indicates that it ran successfully, then go ahead and execute
the right-hand command.

When I make a new kernel, and it's merely a small change (and when I
have other things to do as well -- the usual case), I'll generally do

	cd /sys/i386/conf
	sudo co -l KERNEL
	sudo vi !$
	sudo ci -u !$
	sudo config !$
	cd ../../compile/!$
	sudo make depend && sudo make && sudo make install && sudo reboot

if it's on a machine that isn't otherwise in use (such as one I'm
setting up for someone else).

david
-- 
David Wolfskill		UNIX System Administrator
dhw@whistle.com		voice: (650) 577-7158	pager: (650) 371-4621

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808311706.KAA21737>