help-make
[Top][All Lists]
Advanced

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

Re: make not expanding variables


From: Paul Smith
Subject: Re: make not expanding variables
Date: Sat, 09 Aug 2014 18:52:42 -0400

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]