diff options
author | Mattias Andrée <maandree@operamail.com> | 2012-08-19 19:13:55 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2012-08-19 19:13:55 +0200 |
commit | 924a2ab8edcbe6a4058a4336b7f331c3f3810727 (patch) | |
tree | 5d42a5235130aecd3513b3ae76fada43e60a0239 | |
parent | c4b5146873f681544d21339bf6278c2b89e85790 (diff) | |
download | ponysay-924a2ab8edcbe6a4058a4336b7f331c3f3810727.tar.gz ponysay-924a2ab8edcbe6a4058a4336b7f331c3f3810727.tar.bz2 ponysay-924a2ab8edcbe6a4058a4336b7f331c3f3810727.zip |
bash script redefinement
-rwxr-xr-x | ponysay | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -3,23 +3,23 @@ INSTALLDIR="$(dirname $( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))" LIBDIR="$INSTALLDIR/lib/ponysay" +# The truncater executable 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 { - 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 else - if [[ -f $truncatercmd ]]; then - $truncatercmd $scrw - else - cat - fi + $truncatercmd $scrw fi } # Ponies use UTF-8 drawing characters. Prevent a Perl warning. export PERL_UNICODE=S +# Run ponysay "$0.py" "$@" | wtrunc |