Don't use "echo -n" in shell scripts

The standard says:

If the first operand is -n, or if any of the operands contain a
backslash ( '\' ) character, the results are implementation-defined.

On OS X it simply prints the "-n" string and everything which follows,
including the newline.

Use printf instead.
This commit is contained in:
Jiří Techet 2015-02-06 00:32:10 +01:00
parent 47a5b9fc5f
commit ca21a8759a
2 changed files with 2 additions and 2 deletions

View File

@ -27,7 +27,7 @@ EOF
# Print a nice top bar
# description + ' : ' + value
total=`expr $dlen + 3 + $vlen`
for i in `seq 1 $total`; do echo -n '-'; done
for i in `seq 1 $total`; do printf '-'; done
echo
# And print the actual content

View File

@ -92,7 +92,7 @@ else
do
# maybe the regexp can be optimized, regexps are not my best friends
creationdate=`grep "PO-Revision-Date:" po/$lang.po | sed 's/.*: \([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} [0-9]\{2\}:[0-9]\{2\}[+|-][0-9]\{4\}\).*/\1/'`
echo -n $eswitch $lang"\t("$creationdate"):\t"
printf "%s %s\t(%s):\t" "$eswitch" "$lang" "$creationdate"
msgfmt --check --statistics po/$lang.po;
done
fi