diff options
author | Mattias Andrée <maandree@operamail.com> | 2012-08-16 18:27:20 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2012-08-16 18:27:20 +0200 |
commit | 23d84d1b553d4e820b5a3ce0d388247ee670e20c (patch) | |
tree | a04238fa4dc702635c97af491618489819ba3eab | |
parent | e3c9cdfc95673abd60990b54fad036c37b6ef0a4 (diff) | |
download | ponysay-23d84d1b553d4e820b5a3ce0d388247ee670e20c.tar.gz ponysay-23d84d1b553d4e820b5a3ce0d388247ee670e20c.tar.bz2 ponysay-23d84d1b553d4e820b5a3ce0d388247ee670e20c.zip |
portability: [[ is not recongised by dash
-rw-r--r-- | Makefile | 10 | ||||
-rwxr-xr-x | ponysay | 44 | ||||
-rwxr-xr-x | pq4ps | 2 |
3 files changed, 28 insertions, 28 deletions
@@ -150,10 +150,10 @@ ttyponies: mkdir -p "ttyponies" for pony in $$(ls --color=no "ponies/"); do \ echo "building ttypony: $$pony" ;\ - if [[ `readlink "ponies/$$pony"` = "" ]]; then \ + if [ `readlink "ponies/$$pony"` = "" ]; then \ ponysay2ttyponysay < "ponies/$$pony" | tty2colourfultty -c 1 -e > "ttyponies/$$pony" ;\ git add "ttyponies/$$pony" ;\ - elif [[ ! -f "ttyponies/$$pony" ]]; then \ + elif [ ! -f "ttyponies/$$pony" ]; then \ ln -s `readlink "ponies/$$pony"` "ttyponies/$$pony" ;\ git add "ttyponies/$$pony" ;\ fi \ @@ -163,9 +163,9 @@ pdfmanual: texi2pdf "manuals/ponysay.texinfo" git add "manuals/ponysay.texinfo" "ponysay.pdf" for ext in `echo aux cp cps fn ky log pg toc tp vr`; do \ - (if [[ -f "ponysay.$$ext" ]]; then unlink "ponysay.$$ext"; fi); \ + (if [ -f "ponysay.$$ext" ]; then unlink "ponysay.$$ext"; fi); \ done - if [[ -d "ponysay.t2d" ]]; then rm -r "ponysay.t2d"; fi + if [ -d "ponysay.t2d" ]; then rm -r "ponysay.t2d"; fi submodules: clean (cd "ponyquotes4ponysay/"; make clean) @@ -174,7 +174,7 @@ submodules: clean quotes: submodules (cd "ponyquotes4ponysay/"; make -B) - if [[ -d quotes ]]; then git rm "quotes/"*.*; fi + if [ -d quotes ]; then git rm "quotes/"*.*; fi mkdir -p "quotes" cp "ponyquotes4ponysay/ponyquotes/"*.* "quotes" git add "quotes/"*.* @@ -27,8 +27,8 @@ scrh=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 1` # Screen height # KMS ponies extension kmscmd="" -[[ "$TERM" = "linux" ]] && kmscmd=$(for c in $(echo $PATH":" | sed -e 's/:/\/ponysay2kmsponysay /g'); do if [[ -f $c ]]; then echo $c; break; fi done) -[[ ! "$kmscmd" = "" ]] && TERM="-linux-" +[ "$TERM" = "linux" ] && kmscmd=$(for c in $(echo $PATH":" | sed -e 's/:/\/ponysay2kmsponysay /g'); do if [ -f $c ]; then echo $c; break; fi done) +[ ! "$kmscmd" = "" ] && TERM="-linux-" # Directories for installed ponies files if [ "$TERM" = "linux" ]; then @@ -40,8 +40,8 @@ else fi # Cowsay script -if [[ ${0} == *ponythink ]]; then - if [[ "$PONYSAY_COWTHINK" = "" ]]; then +if [ ${0} == *ponythink ]; then + if [ "$PONYSAY_COWTHINK" = "" ]; then cmd=cowthink customcmd=0 else @@ -49,7 +49,7 @@ if [[ ${0} == *ponythink ]]; then customcmd=1 fi else - if [[ "$PONYSAY_COWSAY" = "" ]]; then + if [ "$PONYSAY_COWSAY" = "" ]; then cmd=cowsay customcmd=0 else @@ -67,15 +67,15 @@ version() { # Pony list function list() { - if [[ -d $SYSTEMPONIES ]]; then + if [ -d $SYSTEMPONIES ]; then echo -e "\\e[01mponyfiles located in $SYSTEMPONIES:\\e[21m" perl $listcmd $scrw $(ls --color=no $SYSTEMPONIES | sed -e 's/\.pony$//' | sort) | $qlistcmd fi - if [[ -d $HOMEPONIES ]]; then + if [ -d $HOMEPONIES ]; then echo -e "\\e[01mponyfiles located in $HOMEPONIES:\\e[21m" perl $listcmd $scrw $(ls --color=no $HOMEPONIES | sed -e 's/\.pony$//' | sort) | $qlistcmd fi - if [[ ! -d $SYSTEMPONIES ]] && [[ ! -d $HOMEPONIES ]]; then + if [ ! -d $SYSTEMPONIES ] && [ ! -d $HOMEPONIES ]; then echo >&2 "All the ponies are missing! Call the Princess!" fi } @@ -106,14 +106,14 @@ _linklist() { linklist() { _linklist $SYSTEMPONIES - if [[ -d $HOMEPONIES ]]; then + if [ -d $HOMEPONIES ]; then _linklist $HOMEPONIES fi } # Pony quotes ponyquotes() { - [[ "$TERM" = "-linux-" ]] && TERM="linux" + [ "$TERM" = "-linux-" ] && TERM="linux" "$0" ${wrap:+-W$wrap} $("$quotecmd" "$*") } @@ -146,10 +146,10 @@ say() { export PERL_UNICODE=S # Clear screen in TTY - ( [[ "$TERM" = "linux" ]] || [[ "$TERM" = "-linux-" ]]) && echo -ne '\e[H\e[2J' + ( [ "$TERM" = "linux" ] || [ "$TERM" = "-linux-" ]) && echo -ne '\e[H\e[2J' # Set PONYSAY_SHELL_LINES to default if not specified - [[ "$PONYSAY_SHELL_LINES" = "" ]] && PONYSAY_SHELL_LINES=2 + [ "$PONYSAY_SHELL_LINES" = "" ] && PONYSAY_SHELL_LINES=2 # Width trunction function wtrunc { @@ -175,12 +175,12 @@ say() { } # Simplification of customisation of cowsay - if [[ $customcmd = 0 ]]; then + if [ $customcmd = 0 ]; then function cowcmd { pcmd='#!/usr/bin/perl\nuse utf8;' - ccmd=$(for c in $(echo $PATH":" | sed -e 's/:/\/'"$cmd"' /g'); do if [[ -f $c ]]; then echo $c; break; fi done) + ccmd=$(for c in $(echo $PATH":" | sed -e 's/:/\/'"$cmd"' /g'); do if [ -f $c ]; then echo $c; break; fi done) - if [[ ${0} == *ponythink ]]; then + if [ ${0} == *ponythink ]; then cat <(echo -e $pcmd) $ccmd > "/tmp/ponythink" perl '/tmp/ponythink' "$@" rm '/tmp/ponythink' @@ -195,7 +195,7 @@ say() { fi # KMS ponies support - if [[ "$kmscmd" = "" ]]; then + if [ "$kmscmd" = "" ]; then function runcmd { cowcmd -f "$pony" "$@" } @@ -220,7 +220,7 @@ say() { # If no stdin and no arguments then print usage and exit -if [[ -t 0 && $# == 0 ]]; then +if [ -t 0 && $# == 0 ]; then usage exit fi @@ -257,16 +257,16 @@ fi # Select random pony for the set of -f arguments -if [[ ! ${#ponies[@]} == 0 ]]; then +if [ ! ${#ponies[@]} == 0 ]; then pony="${ponies[$RANDOM%${#ponies[@]}]}" fi # Pony not a file? Search for it -if [[ ! -f $pony ]]; then +if [ ! -f $pony ]; then ponies=() - [[ -d $SYSTEMPONIES ]] && ponies+=( "$SYSTEMPONIES"/$pony.pony ) - [[ -d $HOMEPONIES ]] && ponies+=( "$HOMEPONIES"/$pony.pony ) + [ -d $SYSTEMPONIES ] && ponies+=( "$SYSTEMPONIES"/$pony.pony ) + [ -d $HOMEPONIES ] && ponies+=( "$HOMEPONIES"/$pony.pony ) if (( ${#ponies} < 1 )); then echo >&2 "All the ponies are missing! Call the Princess!" @@ -279,7 +279,7 @@ fi # Print pony with message -if [[ -n "$*" ]]; then +if [ -n "$*" ]; then # Handle a message given via arguments say <<<"$*" else @@ -2,7 +2,7 @@ INSTALLDIR="$(dirname "$(dirname "$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )")")" # Get main bash script directory's parent -if [[ $# == 1 ]] && [[ "$1" == '-l' || "$1" == '--list' ]]; then +if [ $# == 1 ] && [ "$1" == '-l' || "$1" == '--list' ]; then perl "$0.pl" "$INSTALLDIR" | cut -d @ -f 1 | uniq else _ponies="$(perl "$0.pl" "$INSTALLDIR")" |