Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Aug 2002 13:16:17 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Gavin Atkinson <gavin@ury.york.ac.uk>
Cc:        The Anarcat <anarcat@anarcat.ath.cx>, "C.J." <clayton@frii.net>, freebsd-stable@FreeBSD.ORG, tjr@FreeBSD.ORG
Subject:   Re: /bin/sh changed?
Message-ID:  <20020807111616.GA64887@falcon.midgard.homeip.net>
In-Reply-To: <Pine.BSF.4.33.0208071035470.65875-100000@ury.york.ac.uk>
References:  <20020806230018.GC1019@lenny.anarcat.ath.cx> <Pine.BSF.4.33.0208071035470.65875-100000@ury.york.ac.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Aug 07, 2002 at 10:40:47AM +0100, Gavin Atkinson wrote:
> On Tue, 6 Aug 2002, The Anarcat wrote:
> 
> > Note that the mysql script is quite odd, in itself. It comes back to:
> >
> > sh -c 'true & && echo foo'
> >
> > which is quite foolish anyways.
> 
> I don't see what the problem with this is, and am of the opinion that if
> this particular construct does not work, it should. (Note i'm not talking
> about the obviously wrong "||exit 1" following a line which does not end
> with a backslash).
> 
> Surely, the construct "foo & && echo foo" should be allowable, and should
> mean "run foo in the background, and if successfull, say so". If foo is
> not found, or not executable, or if the shell couldn't fork due to low
> memory, then don't print that it was successful. This is what I have used
> it for in the past.

It don't think it worked for that anyway. 
Try running "sh -c '/nosuchfile & && echo foo'" (with a /bin/sh from
before this change.) I think it will print "foo" even if /nosuchfile
doesn't exist. (I have updated all my FreeBSD systems so I can't test
it there, but that's the way it works on NetBSD which I believe has the
same shell as FreeBSD.)


The construction "cmd1 && cmd2" is supposed to run cmd2 iff the
exit status of cmd1 is 0. When you do cmd1 & && cmd2 the exit status of
cmd1 is unknown and therefore && is fairly meaningless.

It can also be noted that zsh, bash and the Solaris /bin/sh all
disallow the "cmd1 & && cmd2" construction which suggests that it
shouldn't have been accepted by /bin/sh on FreeBSD in the first place.



-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se

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




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