From 7dced5dd382ecebcde1f84a80f5f734b0fd046c2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 24 Jul 2012 14:57:44 +0200 Subject: fix ponysay -L + fix for issue 53 --- ponysay | 80 +++++++---------------------------------------------------------- 1 file changed, 8 insertions(+), 72 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 1c7ff4e..76bc94f 100755 --- a/ponysay +++ b/ponysay @@ -39,7 +39,11 @@ version() { scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2` listcmd="${SCRIPTDIR}/../lib/ponysay/list.pl" +linklistcmd="${SCRIPTDIR}/../lib/ponysay/linklist.pl" truncatercmd="${SCRIPTDIR}/../lib/ponysay/truncater" +[[ -f "./ponysaylist.pl" ]] && listcmd="./ponysaylist.pl" +[[ -f "./ponysaylinklist.pl" ]] && linklistcmd="./ponysaylinklist.pl" +[[ -f "./ponysaytruncater" ]] && truncatercmd="./ponysaytruncater" haspq=1 if [[ -f './pq4ps-list' ]]; then @@ -87,75 +91,7 @@ _linklist() { scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2` - perl '/dev/stdin' $(echo $args) < '/dev/shm/.ponysay~' -#!/usr/bin/perl - -#Author: Mattias Andrée (maandree@kth.se) - -%hash = (); -\$argc = @ARGV; - -\$i = 0; -while (\$i < \$argc) -{ - \$source = \$ARGV[\$i]; - \$i += 1; - \$target = \$ARGV[\$i]; - \$i += 1; - if (\$source eq \$target) - { - \$hash{\$source} = [ () ]; - } -} - -\$i = 0; -while (\$i < \$argc) -{ - \$source = \$ARGV[\$i]; - \$i += 1; - \$target = \$ARGV[\$i]; - \$i += 1; - unless (\$source eq \$target) - { - push @{ \$hash{\$target} }, \$source; - } -} - -\$i = 0; -while (\$i < \$argc) -{ - \$source = \$ARGV[\$i]; - \$i += 1; - \$target = \$ARGV[\$i]; - \$i += 1; - if (\$source eq \$target) - { - @list = @{ \$hash{\$source} }; - \$first = 1; - print \$source; - foreach \$link (@list) - { - if (\$first eq 1) - { - print " (".\$link; - \$first = 0; - } - else - { - print " ".\$link; - } - } - if (\$first eq 0) - { - print ")"; - } - print "\n"; - } -} -EOF - - perl $listcmd $scrw $(cat "/dev/shm/.ponysay~") | sed -e 's/_/ /g' | qlist - rm '/dev/shm/.ponysay~' + perl $listcmd $scrw $(perl $linklistcmd $(echo $args) | sed -e 's/ /_/g') | sed -e 's/_/ /g' | qlist } linklist() { @@ -237,9 +173,9 @@ say() { 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 - cat <(echo -e $pcmd) $ccmd > "/dev/shm/.ponythink" - perl '/dev/shm/.ponythink' "$@" - rm '/dev/shm/.ponythink' + cat <(echo -e $pcmd) $ccmd > "/tmp/.ponythink" + perl '/tmp/.ponythink' "$@" + rm '/tmp/.ponythink' else perl <(cat <(echo -e $pcmd) $ccmd) "$@" fi -- cgit From c374d57fd365833807c2e191178848d76828e859 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 24 Jul 2012 16:16:59 +0200 Subject: /tmp/ponythink instead of /tmp/.ponythink --- ponysay | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 76bc94f..0fdcb18 100755 --- a/ponysay +++ b/ponysay @@ -173,9 +173,9 @@ say() { 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 - cat <(echo -e $pcmd) $ccmd > "/tmp/.ponythink" - perl '/tmp/.ponythink' "$@" - rm '/tmp/.ponythink' + cat <(echo -e $pcmd) $ccmd > "/tmp/ponythink" + perl '/tmp/ponythink' "$@" + rm '/tmp/ponythink' else perl <(cat <(echo -e $pcmd) $ccmd) "$@" fi -- cgit From 4e1655bc0bb213c001848d02342bcdcd60f4f110 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 24 Jul 2012 16:34:44 +0200 Subject: Fix issue #41 --- ponysay | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 0fdcb18..1afb742 100755 --- a/ponysay +++ b/ponysay @@ -1,19 +1,23 @@ #!/usr/bin/env bash version=1.1 -SYSTEMPONIES="/usr/share/ponysay/ponies" -HOMEPONIES="${HOME}/.local/share/ponysay/ponies" SCRIPTDIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Get bash script directory pony="*" wrap="" +SYSTEMPONIES="$(dirname $SCRIPTDIR)/share/ponysay" +HOMEPONIES="${HOME}/.local/share/ponysay" + 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-" if [ "$TERM" = "linux" ]; then - SYSTEMPONIES="/usr/share/ponysay/ttyponies" - HOMEPONIES="${HOME}/.local/share/ponysay/ttyponies" + SYSTEMPONIES="$SYSTEMPONIES/ttyponies" + HOMEPONIES="$HOMEPONIES/ttyponies" +else + SYSTEMPONIES="$SYSTEMPONIES/ponies" + HOMEPONIES="$HOMEPONIES/ponies" fi if [[ "$PONYSAY_COWSAY" = "" ]]; then -- cgit From 7f5fc135cf005a3275e6a648f4f665429193e122 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 24 Jul 2012 18:03:57 +0200 Subject: fix for ponyquotes in tty --- ponysay | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 1afb742..b5d823c 100755 --- a/ponysay +++ b/ponysay @@ -146,7 +146,7 @@ say() { # Ponies use UTF-8 drawing characters. Prevent a Perl warning. export PERL_UNICODE=S - if [ "$TERM" = "linux" ]; then + if [ "$TERM" = "linux" ] || [ "$TERM" = "-linux-" ]; then echo -ne '\e[H\e[2J' fi @@ -244,6 +244,7 @@ if [[ $usepq = 1 ]]; then /usr/bin/pq4ps $@ } fi + [[ "$TERM" = "-linux-" ]] && TERM="linux" $0 ${wrap:+-W$wrap} $(q "$*") exit fi -- cgit