Versions of Echo Vary in Fatally Incompatible Ways
I've been getting back to the basics lately. The following excerpt is from opengroup.org. echo is out. printf is in. I think I remember learning from my mentor, Stu, about 10 years ago...
But instead of integrating this somber fact, I invented all sorts of silly reasons to not adopt printf over echo. One less character. Easier to type. Sounds cooler. Is actually a word. I like delay pedals. Whatever. I wish I had gotten curious about my beliefs instead of rationalizing towards whatever I wanted to be true.
APPLICATION USAGE
It is not possible to use
echoportably across all POSIX systems unless both-n(as the first argument) and escape sequences are omitted.The
printfutility can be used portably to emulate any of the traditional behaviors of theechoutility as follows (assuming that IFS has its standard value or is unset):
- The historic System V
echoand the requirements on XSI implementations in this volume of IEEE Std 1003.1-2001 are equivalent to:printf "%b\n" "$*"- The BSD
echois equivalent to:if [ "X$1" = "X-n" ] then shift printf "%s" "$*" else printf "%s\n" "$*" fiNew applications are encouraged to use
printfinstead ofecho.RATIONALE
The
echoutility has not been made obsolescent because of its extremely widespread use in historical applications. Conforming applications that wish to do prompting without<newline>s or that could possibly be expecting toechoa-n, should use theprintfutility derived from the Ninth Edition system.As specified,
echowrites its arguments in the simplest of ways. The two different historical versions ofechovary in fatally incompatible ways.The BSD
echochecks the first argument for the string-nwhich causes it to suppress the<newline>that would otherwise follow the final argument in the output.The System V
echodoes not support any options, but allows escape sequences within its operands, as described for XSI implementations in the OPERANDS section.The
echoutility does not support Utility Syntax Guideline 10 because historical applications depend onechotoechoall of its arguments, except for the-noption in the BSD version.
-
November 20, 2023
Ending a Dream -
November 19, 2023
Ending a Game -
November 18, 2023
Ending a Company -
September 11, 2023
The COVID-19 Pandemic, Day 1280 -
June 06, 2023
Hauntology -
June 04, 2023
clip-2006-06-28 19;28;26.dv -
May 28, 2023
Ethics of Wayward Otherness -
May 27, 2023
Rebuilding "norns community" -
May 24, 2023
From Surveillance Capitalism to Psy-Ops Capitalism -
April 20, 2023
Annual Report -
February 27, 2023
Versions of Echo Vary in Fatally Incompatible Ways -
February 23, 2023
The COVID-19 Pandemic, Day 1080 -
February 06, 2023
The Software Engineering Code of Ethics and Professional Practice, 1997 -
January 01, 2023
On the Failure of One Small Community in Achieving its Own Ill-defined Dreams and/or Goals...