Eu não posso dizer por que ele não suporta esse argumento (você pode ter que perguntar aos programadores sobre isso). Eu só sei que na minha caixa de linux, eu entendo isso:
$ /bin/echo --help
Usage: /bin/echo [SHORT-OPTION]... [STRING]...
or: /bin/echo LONG-OPTION
Echo the STRING(s) to standard output.
-n do not output the trailing newline
-e enable interpretation of backslash escapes
-E disable interpretation of backslash escapes (default)
--help display this help and exit
--version output version information and exit
If -e is in effect, the following sequences are recognized:
*emphasized text*
$ echo $'\e[34m''COLORS'
NNN the character whose ASCII code is NNN (octal)
\ backslash
\a alert (BEL)
\b backspace
\c produce no further output
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
NOTE: your shell may have its own version of echo, which usually supersedes
the version described here. Please refer to your shell's documentation
for details about the options it supports.
Report echo bugs to [email protected]
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report echo translation bugs to <http://translationproject.org/team/>
- isso não menciona
\e
escapes - diz que é
/bin/echo
do gnu coreutils. Como a Apple altera a origem de seus componentes do sistema unix de tempos em tempos (por exemplo, mover de zsh para bash), verifique se houve uma alteração para/bin/echo
entre o Leopard e o Snow Leopard. Se for gnu, você pode perguntar às pessoas no gnu.org por que elas escolhem não incluir essas sequências.
Quanto a soluções alternativas (isso é mais interessante):
Não usando /bin/echo
, mas o echo
do bash funciona em caixas linux. Se eles mudaram para um bash sem builtin echo (ou algo ainda mais obscuro), você também pode tentar este recurso não muito conhecido do seu shell (funciona pelo menos em bash e zsh):
Words of the form $'string' are treated specially. The word expands to string, with
backslash-escaped characters replaced as specified by the ANSI C standard. Backslash
escape sequences, if present, are decoded as follows:
\a alert (bell)
\b backspace
\e an escape character
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\ backslash
\' single quote
\nnn the eight-bit character whose value is the octal value nnn (one to three
digits)
\xHH the eight-bit character whose value is the hexadecimal value HH (one or
two hex digits)
\cx a control-x character
The expanded result is single-quoted, as if the dollar sign had not been present.
A double-quoted string preceded by a dollar sign ($) will cause the string to be trans‐
lated according to the current locale. If the current locale is C or POSIX, the dollar
sign is ignored. If the string is translated and replaced, the replacement is double-
quoted.
Esta é a parte correspondente da página de man do bash:
$ /bin/echo --help
Usage: /bin/echo [SHORT-OPTION]... [STRING]...
or: /bin/echo LONG-OPTION
Echo the STRING(s) to standard output.
-n do not output the trailing newline
-e enable interpretation of backslash escapes
-E disable interpretation of backslash escapes (default)
--help display this help and exit
--version output version information and exit
If -e is in effect, the following sequences are recognized:
*emphasized text*
$ echo $'\e[34m''COLORS'
NNN the character whose ASCII code is NNN (octal)
\ backslash
\a alert (BEL)
\b backspace
\c produce no further output
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
NOTE: your shell may have its own version of echo, which usually supersedes
the version described here. Please refer to your shell's documentation
for details about the options it supports.
Report echo bugs to [email protected]
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report echo translation bugs to <http://translationproject.org/team/>