Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 May 2005 14:19:17 +0200 (CEST)
From:      Harti Brandt <hartmut.brandt@dlr.de>
To:        Sergey Babkin <babkin@verizon.net>
Cc:        arch@freebsd.org
Subject:   Re: Re: Handling of shell builtins in make(1)
Message-ID:  <20050524141425.A50725@beagle.kn.op.dlr.de>
In-Reply-To: <21970515.1116936525835.JavaMail.root@vms076.mailsrvcs.net>
References:  <21970515.1116936525835.JavaMail.root@vms076.mailsrvcs.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 24 May 2005, Sergey Babkin wrote:

SB>>From: Harti Brandt <hartmut.brandt@dlr.de>
SB>
SB>>On Mon, 23 May 2005, Scott Long wrote:
SB>>
SB>
SB>>SL>> Opinions?
SB>>SL>> 
SB>>SL>> harti
SB>>SL>
SB>>SL>4. Separate /bin/sh into a front end and back end (libsh) and include libsh
SB>>SL>into make.
SB>>SL>
SB>>SL>(running and hiding as I hit the 'send' key)
SB>>
SB>>Would there be other uses for this?
SB>
SB>Yes, I think it could be useful for many programs.

Hmm. What program is executing shell lines?

SB>Or one more option: add a flag to shell that
SB>will make it exit after any command returning non-0
SB>status (at the ";" point, as opposed to "&&", 
SB>"||" and such). Then make could just pass all 
SB>the commands to the shell in one go. And it would 

There is the -e flag which does exactly this. Well, the description in the 
Posix page is a little bit convoluted, but basically it exits when a 
program whose exit status is not expclicitely tested exits with a non-zero
status (this is not entirely correct, but almost).

And currently we actually use sh -ec to execute commands. The problem with 
this is, that Posix wants sh -c. No -e! I think NetBSD has changed this 
(and there is a PR with a patch), but I'm somewhat reluctant to do it, 
because it may break things in unexpected ways. My current plan is to make 
the default -e normally and without -e in Posix mode.


SB>be very useful for all kinds of sysadmin scripts
SB>as well where explicitly checking for the results
SB>of every command is a pain. Even with make it
SB>would be a big improvement, since in the current
SB>format a command failing inside a "for" loop
SB>won't cause make to stop unless explicitly programmed
SB>so, like:
SB>
SB>target: dependencies
SB>   for ... ;\
SB>   do \
SB>     cmd || exit 1; \
SB>   done

This is the canonical way to write this. Our make, however doesn't need 
it.

harti



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