Permalink
Browse files

Merge pull request #66 from thcipriani/enhancement/make-spark-more-po…

…rtable

Remove echo, Create _echo Function, Use printf
  • Loading branch information...
holman committed Sep 23, 2013
2 parents 52a31c3 + 200be3c commit e2f3a98fa9ec543dd939c8f5fd557f1a7e6414f5
Showing with 12 additions and 2 deletions.
  1. +12 −2 spark
View
14 spark
@@ -27,6 +27,16 @@
# Generates sparklines.
#
# $1 - The data we'd like to graph.
+_echo()
+{
+ if [ "X$1" = "X-n" ]; then
+ shift
+ printf "%s" "$*"
+ else
+ printf "%s\n" "$*"
+ fi
+}
+
spark()
{
local n numbers=
@@ -53,9 +63,9 @@ spark()
for n in $numbers
do
- echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]}
+ _echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]}
done
- echo
+ _echo
}
# If we're being sourced, don't worry about such things

0 comments on commit e2f3a98

Please sign in to comment.