Re: [PATCH 2/4] test: due not pass T380.1 for the wrong reasons

Subject: Re: [PATCH 2/4] test: due not pass T380.1 for the wrong reasons

Date: Sun, 20 Feb 2022 11:58:22 +0100

To: David Bremner, Tomi Ollila,


From: Michael J Gruber

David Bremner venit, vidit, dixit 2022-02-20 00:02:40:
> Tomi Ollila <> writes:
> >
> > Wat? afaik echo is builtin in every modern bourne shell derivative...
> >
> > (I tested:
> >  $ bash -c 'builtin echo foo'
> >  foo
> >  $ bash -c 'export PATH=/tmp; echo foo; ls'
> >  foo
> >  bash: ls: command not found
> > )
> Oops. That's what I get for believing "which". Which is another tale of
> woe, of course. Builtin in zsh, and not in bash. Not that it matters
> here, but probably why it doesn't know about bash builtins.

echo is both a builtin (for bash etc) and a command:

$ type echo
echo is a shell builtin

$ which echo

The latter is part of GNU coreutils (sh-utils) and often used when one
wants to avoid shell pecularities.

printf is a builtin

Due to the way the builtins were specified (or underspecified in the
case of echo) in POSIX, the printf builtin is more portable than the
echo builtin.

As a rule of thumb, the echo builtin is OK if you don't need options
(nor special control sequences) but want a newline at the end of the
output anyways; use printf if you need options or format strings.

Alternatively, require GNU coreutils and use /usr/bin/echo.


P.S.: I haven't forgotten about the series but it needs quite a bit of
rework as we found out.
notmuch mailing list --
To unsubscribe send an email to