help-make
[Top][All Lists]
Advanced

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

Re: make not expanding variables


From: David Boyce
Subject: Re: make not expanding variables
Date: Sat, 9 Aug 2014 19:42:55 -0400

We're in danger of getting way off topic here so I will say only that
our experiences differ since I remember encountering at least one
major bug which was not a POSIX compliance thing in dash, though this
was a year or two ago and I can't for the life of me remember the
details.

Also, I was not arguing that "all shells are [or should be] bash",
rather that dash is not sufficiently ready (in my experience) for duty
as /bin/sh. Given that the OP is on Ubuntu, and if we stipulate for
the sake of the argument that dash is broken, then setting SHELL to
bash seems preferable to any other alternative such as zsh.

David

On Sat, Aug 9, 2014 at 6:52 PM, Paul Smith <address@hidden> wrote:
> On Sat, 2014-08-09 at 05:21 -0400, David Boyce wrote:
>> The responses above have analyzed and solved the problem but not
>> explained it completely. Let me clarify the basic fact, which is that
>> Ubuntu (and only Ubuntu) has chosen to make their /bin/sh be a copy of
>> (or symlink to) /bin/dash. Dash is a recent entrant which is intended
>> to be simple, minimal, and uncomplicated. The problem is, all those
>> words sound nice but they translate to "not having all the features of
>> traditional shells". Since make operates with SHELL=/bin/sh, you are
>> by default using dash on Ubuntu but bash on other Linux.
>>
>> I'm not a big fan of Ubuntu's decision. I've found dash to be buggy as
>> well as minimal and it's been responsible for many weird make
>> behaviors in my day job. There is an "official" command you can run to
>> switch /bin/sh back to /bin/bash globally (no memory, google for it),
>> or you can hack the link unofficially though that's not recommended.
>> Alternatively, as Rakesh suggested, you can embed SHELL=/bin/bash in
>> the makefile.
>
> Allow me to make a counter-point:
>
> The main goal of dash is to be a POSIX-compliant shell, and not provide
> any non-POSIX extra features (or in any event, not provide any non-POSIX
> extra features which would make a POSIX-compliant shell script not work
> as expected).
>
> If you write the line:
>
>   cp foo.{c,h} bar
>
> in a POSIX-compliant shell then, because POSIX shells don't have any
> facility for brace expansion, it would expect to copy the literal file
> named 'foo.{c,h}' to bar.  On bash, or other shells that do support
> brace expansion, this would do something different and so this leads to
> a non-compliant shell.
>
> As someone who spends a lot of time working with embedded systems using
> busybox or similar with a built-in POSIX-only shell, where the size of
> bash is far too much to be tolerated, I appreciate Ubuntu taking a stand
> here.  Forcing people to understand that bash is not standard and pay
> attention to writing standard shell scripts is a great benefit to me.
>
> And, of course, bash is not the default /bin/sh on non-GNU/Linux
> operating systems so if you care about that kind of portability you
> should also pay attention to this.  IMO "all shells are bash" is the
> same kind of fallacy that we had with "all the world's a VAX" [1] and
> should similarly be avoided.
>
> I haven't personally experienced any bugs in using dash as /bin/sh in my
> makefiles, as long as I use only POSIX-compliant features.
>
> My recommendation is to write your makefile rules to use POSIX shell
> features only, and not add "SHELL = /bin/bash" to your makefiles.  But,
> that's up to you of course.
>
>
> [1] http://www.catb.org/jargon/html/V/vaxocentrism.html
>



reply via email to

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