[Top][All Lists]

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

Re: echo fix

From: Bob Proulx
Subject: Re: echo fix
Date: Sat, 13 Mar 2004 17:24:42 -0700
User-agent: Mutt/1.3.28i

First, thanks for submitting this suggestion.  However, I doubt it
will be implemented.

Nathan W. Bachmeier wrote:
> Hi, this isn't really a bug fix as more of a very needed option to echo.
> By adding the option -i echo will first read stdin and echo that.
> example:
> $echo hi | echo -in there
> $hi there

I see that you use the -n option to suppress the newline from the
first part.  But the definition of -n is to suppress the trailing
newline from echo.  The trailing newline in the example would be the
one after "there" not the one after "hi".  Sorry, but I did not unpack
your patch to see what you were really doing.  But I think you might
want to avoid the newline on input in your case.

  printf hi | echo -i there  # hypothetical case

Personally I think adding this to echo is the wrong direction.  There
is already cat which reads and echos standard input.  One alternate
implementation which is the same as your example might be the

  echo hi | echo $(cat) there
  hi there

That seems much simpler.  The intesting question is what to do about
newlines in the input.  Your example does not make clear what to do
with multiple line input for instance.

  printf "hello\ngoodbye\n" | echo $(cat) there
  hello goodbye there

But even if you did convince the coreutils maintainer of the utility
of this it would be useless without convincing the shells to implement
it as well.  The 'echo' command is almost always called as a shell

  type echo
  echo is a shell builtin

The standalone implementation is for consistency with programs which
can call external programs so that builtins such as echo are also
provided externally even when there is no shell at that point.  Such
as in this example.

  find /tmp -exec echo {} \;

The standalone implementation should remain compatible with the shell
built-in implementation.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]