Re: [RFC] war on echo in scripts

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

 



On Fri, Jul 9, 2010 at 02:46, Jonathan Nieder <jrnieder@xxxxxxxxx> wrote:
> Andreas Schwab wrote:
>> Jonathan Nieder <jrnieder@xxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]