X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fscripts%2Fscrollbar;h=388bea8e137c8429c841fa3c90307a337a739233;hb=cce855bc5b117cb7ae70064131120687bc69fac0;hp=c177179e778cc9335f9c292d7e73b002842eec0b;hpb=e8ce775db824de329b81293b4e5d8fbd65624528;p=platform%2Fupstream%2Fbash.git diff --git a/examples/scripts/scrollbar b/examples/scripts/scrollbar index c177179..388bea8 100755 --- a/examples/scripts/scrollbar +++ b/examples/scripts/scrollbar @@ -9,17 +9,17 @@ # converted from ksh syntax to bash v2 syntax by Chet Ramey WIDTH=${COLUMNS:-80} +WMINUS=$(( $WIDTH - 1 )) [ $# -lt 1 ] && set -- TESTING -# Posix.2 compatible printf command or bash loadable builtin -# in examples/loadables/printf +# use the bash-2.02 printf builtin Text=$(printf "%-${WIDTH}s" "$*") -Text=$(echo "$Text" | tr ' ' '_') +Text=${Text// /_} while : do printf "%-.${WIDTH}s\r" "$Text" - LastC=$(expr "$Text" : '.*\(.\)$') - Text=$(printf "%-.${WIDTH}s" "$LastC$Text") + LastC=${Text:${WMINUS}:1} + Text="$LastC""${Text%?}" done