2023-09-01 07:15:14 -0500, Eric Blake: [...] > > Note that in bash, you need both > > > > shopt -s xpg_echo > > set -o posix > > > > To get a XSI echo. Without the latter, options are still > > recognised. You can get a XSI echo without those options with: > > > > xsi_echo() { > > local IFS=' ' - > > set +o posix > > echo -e "$*\n\c" > > } > > > > The addition of those \n\c (noop) avoids arguments being treated as > > options if they start with -. > > As an extension, Bash (and Coreutils) happen to honor \c always, and > not just for %b. But POSIX only requires \c handling for %b. > > And while Issue 8 has taken steps to allow implementations to support > 'echo -e', it is still not standardized behavior; so your xsi_echo() > is bash-specific (which is not necessarily a problem, as long as you > are aware it is not portable). [...]
Yes, none of local (from ash I believe), the posix option (several shells have an option called posix all used to improve POSIX conformance, bash may have been the first) nor -e (from Research Unix v8) are standard, that part was about bash specifically (as the thread is also posted on gnu.bash.bug). BTW, that xsi_echo is not strictly equivalent to a XSI echo in the case where the last character of the last argument is an unescaped backslash or a character whose encoding ends in the same byte as the encoding of backslash. -- Stephane