Re: [bug?] echo -n does not work as described

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Kevin Korb <kmk@xxxxxxxxxxxxxx> [12.11.2015 08:52]:
> $ echo -n testing
> - -n testing

in POSIX the '-n' switch (and -e) is undefined.
you can work around this via hijacking the call:

#!/bin/sh
echo()
{
	case "$1" in
		'-n')
			shift
			printf '%s' "$@"
		;;
		*)
			printf '%s\n' "$@"
		;;
	esac
}

echo foo
echo -n bar

if you really want to remove all the bashisms, it
can be a lot of work. dont blame dash for this, but
the script author. also consider using shellsheck.net
for this with the correct shebang.

bye, bastian
--
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



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux