[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature request: echo --
From: |
Bob Proulx |
Subject: |
Re: feature request: echo -- |
Date: |
Tue, 19 Oct 2021 01:06:12 -0600 |
Florent Flament wrote:
> Out of curiosity, would it possible to have the `echo` command output
> the string "-n" ?
>
> ```
> $ POSIXLY_CORRECT=1 /bin/echo -n
> ```
But the standards do actually mention -n. The behavior you see with
POSIXLY_CORRECT=1 is conforming behavior.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html#tag_20_37
If the first operand is -n, or if any of the operands contain a <backslash>
character, the results are implementation-defined.
Unix v7 echo accepted -n as an option and did not print it. Same with
BSD. It is too late to mess with it now.
On a practical level why is it an issue at all? If there is any
concern about printing -n then use 'printf' as that is a much better
solution for arbitrary strings.
Also note that most shells include 'echo' as a builtin command which
will be different from the coreutils standalone executable. Most
users should look to their shell for their echo implementation instead.
Bob
- feature request: echo --, Roger Pack, 2021/10/15
- Re: feature request: echo --, Philip Rowlands, 2021/10/15
- Re: feature request: echo --, Pádraig Brady, 2021/10/15
- Re: feature request: echo --, Leslie S Satenstein, 2021/10/15
- Re: feature request: echo --, Florent Flament, 2021/10/16
- Re: feature request: echo --,
Bob Proulx <=
- Re: feature request: echo --, Florent Flament, 2021/10/19
- Re: feature request: echo --, Bob Proulx, 2021/10/19
- Re: feature request: echo --, Florent Flament, 2021/10/20
- Re: feature request: echo --, Bob Proulx, 2021/10/21
- Re: feature request: echo --, Florent Flament, 2021/10/21