make-alpha
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: .ONESHELL enhancement?


From: David Boyce
Subject: Re: .ONESHELL enhancement?
Date: Tue, 22 Sep 2009 14:46:45 -0400

On Tue, Sep 22, 2009 at 1:53 PM, Eli Zaretskii <address@hidden> wrote:
> "&&" works on Windows only with cmd.exe (and probably also 4nt and
> friends), but not for command.com.  The latter cannot support multiple
> commands on a single command line, so we will need to punt.
>
> And for the DOS (a.k.a. DJGPP) port, you will need to use ";" instead,
> since the `system' function in DJGPP enhances the system shell with
> several features, including this one.

Thanks, worth noting. It would probably be best to document .ONESHELL
as a *request* to group commands together "wherever practical",
leaving wiggle room for funky cases like these.

It's also worth noting that there exists a corner case where it would
NOT save processes. E.g.:

foo:
        touch bar
        mv bar foo

normally requires two fork/execs due to the "fast path", whereas when
throwing in && it would technically require three. I don't think this
is a real concern because

- It's a corner case with trivial consequences which would typically
be swamped by the positive effects.
- It's a corner case you only get when you ask for it.
- Most modern shells are smart enough on their own to skip forking
before the "mv", so we're back to the original two processes.
- It's still aesthetically superior because "/bin/sh -c "touch bar &&
mv bar foo" self-documents that bar is a temporary file and that the
construction of foo is logically atomic, whereas the original does
not.

DSB




reply via email to

[Prev in Thread] Current Thread [Next in Thread]