2015-11-11 22:46:02 -0500, Kevin Korb: [...] > >>> NOTE: your shell may have its own version of echo, which > >>> usually super‐ sedes the version described here. Please refer > >>> to your shell's docu‐ mentation for details about the options > >>> it supports. > > > >> By the way, 'echo -n' is non-portable, and POSIX says you should > >> use 'printf' instead. > > If dash refuses to supply a compatible version of echo then dash must > not include a builtin version of echo. If dash didn't have a broken > embedded version of echo I wouldn't have a problem. [...] To clarify, a few things, sh and the POSIX/Unix utilities like C nowadays is a language that has a (well several) standard that defines it, and several existing implementations of interpreters that interpret that language. Among the most recognised specifications, we have POSIX and Unix. Both specifications have now been merged. To simplify, the Unix spec is like the POSIX spec but where a few optional parts are required. So basically we have the POSIX syntax for sh and utilities and the Unix syntax. In the POSIX syntax, the behaviour for: echo -n whatever is unspecified. That means that a POSIX conformant script, or a script written to be portable to POSIX conformant systems must not call echo with a first argument that may be -n. We're told to use printf instead there: printf %s "$var" instead of echo -n "$var" Same goes for any argument that contains backslash character. In the Unix syntax however, the behaviour of echo is clearly specified. echo -n whatever is required to output "-n whatever<newline>", so your dash is both POSIX and Unix conformant in that regard. The builtin echo of bash, by default is neither POSIX nor Unix conformant unless both the xpg_echo and posix (that one enabled when called as sh) options have been enabled. More details at: http://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo In short, don't use echo. -- Stephane -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html