Subject: RE: make, sh, bash and echo
From: David Starks-Browning <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Tue, 31 Jul 2001 18:38:08 +0100

Andrej is correct, but here's a more detailed explanation:

'make' uses /bin/sh to execute commands.  'sh' is really ash, which
has its own 'echo' builtin.  That echo does not have the same options as
/bin/echo.  Bash's echo builtin *does* use the -ne options.  But even
that one is not as full featured as /bin/echo, which is part of the
sh-utils package.  (In the bash shell, type "echo --version" and
"/bin/echo --version".)

Even if PATH is set correctly, the ash shell builtins take precedence.

Use /bin/echo if you want the fancy echo, regardless of shell.
But that's only a "sure thing" in Cygwin.  /bin/echo on other UNIX's
may not be full-featured.

Hope this helps.

Regards,
David
(Cygwin FAQ maintainer)

On Tuesday 31 Jul 01, Borsenkow Andrej writes:
> 
> >
> > Makefile:
> >
> > all:
> > 	echo -ne "foo\nbar" > bar
> >
> > $ make --unix
> > $ cat bar
> > -ne foo\nbar
> >
> > Seems like the wrong echo is executed because SHELL is
> > /bin/sh.exe and PATH isn't set correctly, you know why.
> > On Unix of course the right one and only echo is executed.
> 
> It is inherently non-portable. You cannot expect echo to understand any
> option at all.
> 
> > If I add the line SHELL=/bin/bash.exe it works the way i expect.
> >
> 
> The way you expect is not neccessarily how it works in real life.
> 
> > Is there any better solution ?
> >
> 
> Yes, use portable constructs. Look in Autoconf manual that has good overview
> of common portability problems with assorted tools (including echo).
> 
> 
> -andrej

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/