mirror of
https://github.com/erkin/ponysay.git
synced 2025-03-17 17:10:01 +01:00
bash script redefinement
This commit is contained in:
parent
c4b5146873
commit
924a2ab8ed
1 changed files with 7 additions and 7 deletions
14
ponysay
14
ponysay
|
@ -3,23 +3,23 @@
|
||||||
INSTALLDIR="$(dirname $( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))"
|
INSTALLDIR="$(dirname $( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))"
|
||||||
LIBDIR="$INSTALLDIR/lib/ponysay"
|
LIBDIR="$INSTALLDIR/lib/ponysay"
|
||||||
|
|
||||||
|
# The truncater executable
|
||||||
truncatercmd="$LIBDIR/truncater"
|
truncatercmd="$LIBDIR/truncater"
|
||||||
|
|
||||||
scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2` # Screen width
|
# Screen width
|
||||||
|
scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2`
|
||||||
|
|
||||||
|
# Output trunction on width
|
||||||
function wtrunc {
|
function wtrunc {
|
||||||
if [ "$PONYSAY_FULL_WIDTH" = 'yes' ] || [ "$PONYSAY_FULL_WIDTH" = 'y' ] || [ "$PONYSAY_FULL_WIDTH" = '1' ]; then
|
if [[ "$PONYSAY_FULL_WIDTH" = 'yes' ]] || [[ "$PONYSAY_FULL_WIDTH" = 'y' ]] || [[ "$PONYSAY_FULL_WIDTH" = '1' ]] || [[ ! -f $truncatercmd ]]; then
|
||||||
cat
|
cat
|
||||||
else
|
else
|
||||||
if [[ -f $truncatercmd ]]; then
|
$truncatercmd $scrw
|
||||||
$truncatercmd $scrw
|
|
||||||
else
|
|
||||||
cat
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ponies use UTF-8 drawing characters. Prevent a Perl warning.
|
# Ponies use UTF-8 drawing characters. Prevent a Perl warning.
|
||||||
export PERL_UNICODE=S
|
export PERL_UNICODE=S
|
||||||
|
|
||||||
|
# Run ponysay
|
||||||
"$0.py" "$@" | wtrunc
|
"$0.py" "$@" | wtrunc
|
||||||
|
|
Loading…
Add table
Reference in a new issue