]> git.ipfire.org Git - thirdparty/bash.git/blame - examples/scripts/scrollbar2
Bash-4.2 patch 45
[thirdparty/bash.git] / examples / scripts / scrollbar2
CommitLineData
cce855bc
JA
1#!/bin/bash
2#
3# scrollbar - display scrolling text
4#
5# usage: scrollbar args
6#
7# A cute hack originally from Heiner Steven <hs@bintec.de>
8#
9# converted from ksh syntax to bash v2 syntax by Chet Ramey
10
11WIDTH=${COLUMNS:-80}
12WMINUS=$(( $WIDTH - 1 ))
13
14[ $# -lt 1 ] && set -- TESTING
15
16# use the bash-2.02 printf builtin
17Text=$(printf "%-${WIDTH}s" "$*")
18
19while :
20do
21 printf "%-.${WIDTH}s\r" "$Text"
22 LastC=${Text:${WMINUS}:1}
23 Text="$LastC""${Text%?}"
24done