holman / spark

▁▂▃▅▂▇ in your shell.

Home Page:http://zachholman.com/spark/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Instead of echo -n use printf

helpermethod opened this issue · comments

Use of printf over echo -n is preferred due to greater portability. Taken from the Application Usage section of the POSIX echo manpage

APPLICATION USAGE

It is not possible to use echo portably across all POSIX systems unless both -n (as the first argument) and escape sequences are omitted.

The printf utility can be used portably to emulate any of the traditional behaviors of > the echo utility as follows (assuming that IFS has its standard value or is unset):

The historic System V echo and the requirements on XSI implementations in this > volume of POSIX.1-2008 are equivalent to:

printf "%b\n" "$*"

The BSD echo is equivalent to:

if [ "X$1" = "X-n" ]
then
shift
printf "%s" "$"
else
printf "%s\n" "$
"
fi

New applications are encouraged to use printf instead of echo.