David Bremner venit, vidit, dixit 2022-02-20 00:02:40:
> Tomi Ollila <tomi.oll...@iki.fi> 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
/usr/bin/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.

Cheers
Michael

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

Reply via email to