Permalink
Browse files

print sparks incrementally instead of building string

This shaves a few lines from the print_ticks function. We
use "printf" instead of "echo -n" as the former is more
portable (although we are hopelessly tied to bash due to the
use of arrays, anyway, so either would be fine).
  • Loading branch information...
1 parent 2243964 commit a179f1f093d19bc2bb141c9d860247aa973119b4 @peff peff committed Nov 15, 2011
Showing with 4 additions and 6 deletions.
  1. +4 −6 spark
View
10 spark
@@ -104,27 +104,25 @@ print_tick()
if [ $result -eq 1 ]
then
- echo "$tick"
+ printf '%s' "$tick"
return
fi
done
last=${#ticks[@]}
- echo ${ticks[$last-1]}
+ printf '%s' ${ticks[$last-1]}
}
# Iterate over all of our ticks and print them out.
#
# Returns nothing.
print_ticks()
{
- tick_string=
for number in ${numbers[@]}
do
- new_tick=$(print_tick $number)
- tick_string=$tick_string$new_tick
+ print_tick $number
done
- echo $tick_string
+ echo
}
while getopts ":h" option; do

0 comments on commit a179f1f

Please sign in to comment.