[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problems with echo. (echo period)
From: |
Aaron Shatters |
Subject: |
Re: Problems with echo. (echo period) |
Date: |
Tue, 17 Apr 2007 21:34:52 -0700 (PDT) |
>Btw, you can have an empty line with cmd's echo if you say `echo""'.
No, for the cmd.exe shell, echo"" doesn't seem to be working.
> shall-i-invoke-a-shell-command-because-of-redirection-or-other-tricky-stuff
> vs. shall-i-just-invoke-the-command-executable-itself-directly decision stuff?
Yes, that is what the problem is.
As for why it is useful to be able to use this feature... consider the
following:
@echo $(VARIABLE)
will print "ECHO is off." if VARIABLE is undefined
I suppose that you could do
ifdef VARIABLE
@echo $(VARIABLE)
endif
but, often times, using other make utilities such as clearmake, dmake, omake...
the following is done
windows:
@echo.$(VARIABLE)
unix:
@echo "$(VARIABLE)"
or the portable implementation:
@$(ECHO)$(VARIABLE)$(ECHOEND)
where,
windows:
ECHO = echo.
ECHOEND =
unix:
ECHO = echo "
ECHOEND = "
This allows VARIABLE to be undefined, resulting in a blank line instead of
"ECHO is off." This also allows you to prefix preformatted whitespace to the
text being echo'ed.
I'm sure that there are nifty workarounds to not being able to use "echo.", but
it seems like the more appropriate thing to do would be to fix make.
One of the workarounds is to do this:
ECHO = echo.
ECHOEND = $(SPACE)2>&1
Since echo never really prints to stderr, this is not going to cause any
problems, but it does force make to use batch mode because it finds a '>'
character in the command. This is pretty much a hack.
And if the next question is, why is this so important?... the answer is... it's
not because there are probably 12 different ways to work your way around it,
however, it is useful to be able to use the shell, in all of it's glory,
without trying to invent hacks to get around some make limitation. It's also
useful to be compatible with other make utilites as much as possible.
Is there any disagreement that this is a limitation of make, and that it
probably should be fixed?
If not... just add
#ifdef WINDOWS32
case '.':
/* Handle special case where echo is immediately following by a '.' */
if ((!unixy_shell) &&
(0 == i) &&
((p - line) >= 4) &&
(0 == strncmp(p-4,"echo",4)))
{
goto slow;
}
/* intentionally omit break;, fall through to default */
#endif
in front of
default:
*ap++ = *p;
break;
in the "construct_command_argv_internal" function
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com