diff options
author | Mattias Andrée <maandree@operamail.com> | 2012-07-24 14:57:44 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2012-07-24 14:57:44 +0200 |
commit | 7dced5dd382ecebcde1f84a80f5f734b0fd046c2 (patch) | |
tree | 25da47a23de211849f093066b3751e7e81845942 /ponysay | |
parent | 80739e89dfd526f0220d33831a02c0462b3a375f (diff) | |
download | ponysay-7dced5dd382ecebcde1f84a80f5f734b0fd046c2.tar.gz ponysay-7dced5dd382ecebcde1f84a80f5f734b0fd046c2.tar.bz2 ponysay-7dced5dd382ecebcde1f84a80f5f734b0fd046c2.zip |
fix ponysay -L + fix for issue 53
Diffstat (limited to 'ponysay')
-rwxr-xr-x | ponysay | 80 |
1 files changed, 8 insertions, 72 deletions
@@ -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) <<EOF | sed -e 's/ /_/g' > '/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 |