FYI the "echo" command is basically made out of footguns and should never be used in a shell script - use printf(1) instead.

@sir Also printf is portable opposed to echo, iirc.

@sir why was echo included in coreutils in the first place when printf already does whatever echo does?

@terra @sir it's marked as shell utility which basically means a shell builtin

@terra @sir I checked, they're both shell builtins and have binaries as well

@terra @sir To quote another echo(1):

"The echo utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification."

Can't have a GNU is Not Unix if you don't reimplement a ubiquitous Unix tool.

That's why it is in coreutils. Why it is in POSIX? You can always make a safe guess at "historical reasons".

@clacke @sir ah thanks, i wasnt sure whether to ask about POSIX or coreutils

I would be delighted if somebody would dig deeper and come out with "Unix XYZ had 'echo' and 'printf' was added in Unix UVW but at that point scripts using 'echo' were already everywhere".

But also people really like not having to type "%s\n".
Turns out there's even a…!

"Unix XYZ" is not even Unix, it's all the way back in Multics, and "Unix UVW" is Ninth Edition Unix.
Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!