You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.6 KiB
93 lines
2.6 KiB
10 years ago
|
http://bugs.gentoo.org/337329
|
||
|
http://bugs.gentoo.org/527848
|
||
|
|
||
|
there's no requirement for `echo` to support escape sequences. bash, by default,
|
||
|
does not, while dash always does. POSIX permits either behavior:
|
||
|
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html
|
||
|
|
||
|
however, since the behavior is not portable, no one should be relying on echo
|
||
|
having any specific behavior. they should use `printf` when they want an escape
|
||
|
sequence. it also makes dash smaller & faster to disable this logic entirely.
|
||
|
|
||
6 years ago
|
--- dash-0.5.10/src/bltin/printf.c
|
||
|
+++ dash-0.5.10/src/bltin/printf.c
|
||
|
@@ -457,22 +457,13 @@
|
||
10 years ago
|
int
|
||
|
echocmd(int argc, char **argv)
|
||
|
{
|
||
6 years ago
|
- const char *lastfmt = snlfmt;
|
||
|
- int nonl;
|
||
10 years ago
|
+ int i;
|
||
6 years ago
|
|
||
|
- if (*++argv && equal(*argv, "-n")) {
|
||
|
- argv++;
|
||
|
- lastfmt = "%s";
|
||
10 years ago
|
+ for (i = 1; i < argc; ++i) {
|
||
|
+ outstr(argv[i], out1);
|
||
6 years ago
|
+ if (1 < argc - 1)
|
||
10 years ago
|
+ outc(' ', out1);
|
||
|
}
|
||
|
-
|
||
|
- do {
|
||
6 years ago
|
- const char *fmt = "%s ";
|
||
|
- char *s = *argv;
|
||
10 years ago
|
-
|
||
6 years ago
|
- if (!s || !*++argv)
|
||
|
- fmt = lastfmt;
|
||
10 years ago
|
-
|
||
6 years ago
|
- nonl = print_escape_str(fmt, NULL, NULL, s ?: nullstr);
|
||
|
- } while (!nonl && *argv);
|
||
10 years ago
|
+ outc('\n', out1);
|
||
|
return 0;
|
||
|
}
|
||
6 years ago
|
--- dash-0.5.10/src/dash.1
|
||
|
+++ dash-0.5.10/src/dash.1
|
||
|
@@ -1182,43 +1182,15 @@
|
||
9 years ago
|
option turns off the effect of any preceding
|
||
|
.Fl P
|
||
|
options.
|
||
|
-.It Xo echo Op Fl n
|
||
|
+.It Xo echo
|
||
|
.Ar args...
|
||
|
.Xc
|
||
|
Print the arguments on the standard output, separated by spaces.
|
||
|
-Unless the
|
||
|
-.Fl n
|
||
|
-option is present, a newline is output following the arguments.
|
||
6 years ago
|
.Pp
|
||
9 years ago
|
-If any of the following sequences of characters is encountered during
|
||
|
-output, the sequence is not output. Instead, the specified action is
|
||
|
-performed:
|
||
|
-.Bl -tag -width indent
|
||
|
-.It Li \eb
|
||
|
-A backspace character is output.
|
||
|
-.It Li \ec
|
||
|
-Subsequent output is suppressed. This is normally used at the end of the
|
||
|
-last argument to suppress the trailing newline that
|
||
|
-.Ic echo
|
||
|
-would otherwise output.
|
||
|
-.It Li \ef
|
||
|
-Output a form feed.
|
||
|
-.It Li \en
|
||
|
-Output a newline character.
|
||
|
-.It Li \er
|
||
|
-Output a carriage return.
|
||
|
-.It Li \et
|
||
|
-Output a (horizontal) tab character.
|
||
|
-.It Li \ev
|
||
|
-Output a vertical tab.
|
||
|
-.It Li \e0 Ns Ar digits
|
||
|
-Output the character whose value is given by zero to three octal digits.
|
||
|
-If there are zero digits, a nul character is output.
|
||
|
-.It Li \e\e
|
||
|
-Output a backslash.
|
||
|
-.El
|
||
|
+No arguments or backslash sequences are supported as they are not portable.
|
||
|
+They will be printed out exactly as passed in.
|
||
6 years ago
|
.Pp
|
||
|
-All other backslash sequences elicit undefined behaviour.
|
||
9 years ago
|
+You can replace `echo -n ...` with the portable `printf %s ...` construct.
|
||
|
.It eval Ar string ...
|
||
|
Concatenate all the arguments with spaces.
|
||
|
Then re-parse and execute the command.
|