Fixing build failures with dash is cool.

The bad thing with fixing build failures with dash is that there are still a lot of open bugs. (Remember, the 0-day NMU policy applies to those, so it’s a good opportunity to improve your NMU karma. And I will sponsor your NMUs if you can’t upload!).

The good thing is that you sometimes run into funny code, like:
clean:
    dh_testdir
    dh_testroot
    pushd docs ; $(MAKE) distclean || true ; popd

Since pushd/popd is a bashism, the Ubuntu patch changed this to:
clean:
    dh_testdir
    dh_testroot
    cd docs ; $(MAKE) distclean || true ; cd $(CURDIR)

Which works, but is … interesting? :-)

11 thoughts on “Fixing build failures with dash is cool.

  1. Doesn’t GNU Make now execute each line of a makefile in a new shell, so it should automatically cd back before the next line of the makefile? (Of course, that’s very non-obvious.)

  2. > Since pushd/popd is a bashism, the Ubuntu patch changed this to:
    > clean:
    > dh_testdir
    > dh_testroot
    > cd docs ; $(MAKE) distclean || true ; cd $(CURDIR)
    >
    > Which works, but is … interesting? :-)

    … and which is also useless since every line in a Makefile works in its own subshell. You don’t need to worry about preserving the directory, it’s already preserved for you. You might as well write:


    clean:
    dh_testdir
    dh_testroot
    $(MAKE) distclean || true

    The || true is to ignore failure when doing distclean, you might as well write:


    clean:
    dh_testdir
    dh_testroot
    -$(MAKE) distclean

  3. Considering how inferior to bash dash is, I really fail to understand why you guys insist on using it as /bin/sh for your build environment…

  4. Ooops. In my previous comment, I forgot that your command was temporarily going into the docs directory. Anyway, since it is in a subshell, no need to cd back into the old directory. So this will do:

    clean:
    dh_testdir
    dh_testroot
    cd docs ; $(MAKE) distclean || true

  5. In addition to size and speed, dash also has fewer extensions to standards, so using dash tends to reveal non-standard constructs.

  6. Another possibility that might be more robust would be something like this

    $ (cd docs; $(MAKE) distclean)

    The commands are run in a sub shell, and the “pop” will happen automatically when the sub shell exits.

Comments are closed.