In Mac's it's -b
, and the default is already 0.
$ man base64
...
OPTIONS
The following options are available:
-b count
--break=count Insert line breaks every count characters. Default is 0, which generates an unbroken stream.
...
One way to have the script work for both is checking for errors:
MYCOMMAND=$(base64 -w0 commands.sh)
if [ $? -ne 0 ]; then
MYCOMMAND=$(base64 commands.sh)
fi
You can also run an explicit test, e.g
echo | base64 -w0 > /dev/null 2>&1
if [ $? -eq 0 ]; then
# GNU coreutils base64, '-w' supported
MYCOMMAND=$(base64 -w0 commands.sh)
else
# Openssl base64, no wrapping by default
MYCOMMAND=$(base64 commands.sh)
fi