Permalink
Browse files

retab

  • Loading branch information...
1 parent e22bb47 commit 388429c90b5370129faabf6e6252b89bd82eca82 @holman committed Nov 17, 2011
Showing with 25 additions and 25 deletions.
  1. +25 −25 spark
View
50 spark
@@ -27,7 +27,7 @@
# Prints the help text for spark.
help()
{
- cat <<EOF
+ cat <<EOF
USAGE:
spark VALUE,...
@@ -45,37 +45,37 @@ EOF
# $1 - The data we'd like to graph.
spark()
{
- local n numbers=
+ local n numbers=
- # find min/max values
- local min=0xffffffff max=0
+ # find min/max values
+ local min=0xffffffff max=0
- for n in ${@//,/ }
- do
- # on Linux (or with bash4) we could use `printf %.0f $n` here to
- # round the number but that doesn't work on OS X (bash3) nor does
- # `awk '{printf "%.0f",$1}' <<< $n` work, so just cut it off
- n=${n%.*}
- (( n < min )) && min=$n
- (( n > max )) && max=$n
- numbers=$numbers${numbers:+ }$n
- done
+ for n in ${@//,/ }
+ do
+ # on Linux (or with bash4) we could use `printf %.0f $n` here to
+ # round the number but that doesn't work on OS X (bash3) nor does
+ # `awk '{printf "%.0f",$1}' <<< $n` work, so just cut it off
+ n=${n%.*}
+ (( n < min )) && min=$n
+ (( n > max )) && max=$n
+ numbers=$numbers${numbers:+ }$n
+ done
- # print ticks
- local ticks=(▁ ▂ ▃ ▄ ▅ ▆ ▇ █)
- local f=$(( (($max-$min)<<8)/(${#ticks[@]}-1) ))
- (( f < 1 )) && f=1
+ # print ticks
+ local ticks=(▁ ▂ ▃ ▄ ▅ ▆ ▇ █)
+ local f=$(( (($max-$min)<<8)/(${#ticks[@]}-1) ))
+ (( f < 1 )) && f=1
- for n in $numbers
- do
- echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]}
- done
- echo
+ for n in $numbers
+ do
+ echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]}
+ done
+ echo
}
[ "$1" == '-h' ] && {
- help
- exit
+ help
+ exit
}
spark ${@:-`cat`}

0 comments on commit 388429c

Please sign in to comment.