Skip to content

Commit e2f3a98

Browse files
committed
Merge pull request holman#66 from thcipriani/enhancement/make-spark-more-portable
Remove echo, Create _echo Function, Use printf
2 parents 52a31c3 + 200be3c commit e2f3a98

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

spark

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727
# Generates sparklines.
2828
#
2929
# $1 - The data we'd like to graph.
30+
_echo()
31+
{
32+
if [ "X$1" = "X-n" ]; then
33+
shift
34+
printf "%s" "$*"
35+
else
36+
printf "%s\n" "$*"
37+
fi
38+
}
39+
3040
spark()
3141
{
3242
local n numbers=
@@ -53,9 +63,9 @@ spark()
5363

5464
for n in $numbers
5565
do
56-
echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]}
66+
_echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]}
5767
done
58-
echo
68+
_echo
5969
}
6070

6171
# If we're being sourced, don't worry about such things

0 commit comments

Comments
 (0)