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

RE: Using 'echo' in a makefile/what shell is used?



>> But on my debian system that help message doesn't print correctly
>> due to '\t' not expanding to tab and '\n' not expanding to cause new
>> lines.  I finally figured out that I can use 'echo -e' to print the
>> help text correction from within gmake.
>
>You have run into one of the most annoying things about bash being
>installed as /bin/sh on a system.  It is almost POSIX compliant.  But
>in this regard is falls down.  POSIX requires echo to interpret quoted
>characters like SysV does.  But bash follows BSD and requires -e.  The
>result of this conflict is that portable scripts can't use this
>feature at all and must avoid it.  It is a shame.  Sigh.
>
>> I'd like to make this the default behavior on my system so the
>> Makefile remains unchanged, however.
>
>About the only thing you can do is install a better /bin/sh
>replacement.  'ash' is probably the best choice in this regard.  Then
>replace the /bin/sh symlink to bash with a symlink to ash.

Sure enough!  That took care of it on my debian box.

>> Can I make the default echo command from within gmake always behave
>> as though it had the '-e' option?
>
>File a bug against bash to convert to POSIX on this point.  It is not
>a make problem.
>

The symlink took care of the unwanted behavior on my system, of course.
For a few other systems where the code is to be compiled I overrode the
variables in the makefile's by starting the compile using a script that
has the desired values of its variables (e.g. make ECHO='echo -e') which
is not terribly inconvenient.  I didn't go so far as to file a bug
report.  I assume it's been a conscious decision on the part of the bash
maintainers.  
But if you think it's an oversight I'll file the bug report.

>Your best option is to avoid echo when using any escape sequences at
>all.  It is a can of worms.  Instead use 'printf' which is a new
>command with no legacy that is required to support the standard
>features on all systems.
>
>  printf "\tfoo: bar\n"

This command isn't on the legacy system I want to keep it interoperable
with.

>[A side note.  You keep calling it 'gmake'.  Why?  Is there another
>option for 'make' on GNU systems?  Why not just call it 'make'?]

It was/is called gmake when installed on Unix systems that already have
another make utility that you prefer not to overwrite.  The user who
wanted to use GNU make made a symbolic link in his 'bin' directory to
gmake.

>
>Bob

Thanks for the detailed info and help.

Kris




Reply to: