git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] war on echo in scripts

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 9, 2010, 11:52 UTC
Message-ID
<AANLkTint6AfhwKdeizt-YVt4O6AZbLG9A5h6ipJyQyIQ@mail.gmail.com>
In-Reply-To
<20100709024633.GA13739@dert.cs.uchicago.edu>
On Fri, Jul 9, 2010 at 02:46, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 16 quoted lines
> Andreas Schwab wrote:
>> Jonathan Nieder <jrnieder@gmail.com> writes:
>
>>>  die() {
>>> -    echo >&2 "$@"
>>> +    printf >&2 '%s\n' "$@"
>>
>> You probably want to use "$*" here, though it wouldn't matter for the
>> uses of die in this file.
>
> Hmm, maybe something like this would be easier.
> [...]
> +echo() {
> +       printf '%s\n' "$*"
> +}
> +
Overriding builtins like this isn't portable.
(Via H.Merijn Brand): This fails on the old HP-UX 10.20 bourne shell:
    > cat xx.sh
    #!/bin/sh
    echo ()
    {
    perl -le'print "Done!"'
    }
    echo 1
    echo Klaar
    > sh xx.sh
    xx.sh[3]: The operation is not allowed in a restricted shell.:
echo is a shell builtin.
    1
    Klaar
Previous: Junio C HamanoNext: Jonathan Nieder
Message 15 of 16 in “rebase -i: use 'read -r' to avoid backslash acting as an escape character”
  1. rebase -i: use 'read -r' to avoid backslash acting as an escape characterMiklos Vajna, Jul 6, 2010
  2. Junio C HamanoJul 7, 2010
  3. Miklos VajnaJul 7, 2010
  4. Santi BéjarJul 7, 2010
  5. Miklos VajnaJul 7, 2010
  6. Junio C HamanoJul 8, 2010
  7. Miklos VajnaJul 8, 2010
  8. [RFC] war on echo in scriptsJonathan Nieder, Jul 8, 2010
  9. Andreas SchwabJul 8, 2010
  10. Jonathan NiederJul 9, 2010
  11. Sverre RabbelierJul 9, 2010
  12. Junio C HamanoJul 9, 2010
  13. Jonathan NiederJul 9, 2010
  14. Junio C HamanoJul 9, 2010
  15. Ævar Arnfjörð BjarmasonJul 9, 2010
  16. Jonathan NiederJul 9, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.