mirror of
https://github.com/erkin/ponysay.git
synced 2025-03-19 10:17:12 +01:00
fix ponysay -L + fix for issue 53
This commit is contained in:
parent
80739e89df
commit
7dced5dd38
3 changed files with 82 additions and 72 deletions
2
Makefile
2
Makefile
|
@ -61,6 +61,7 @@ install:
|
||||||
mkdir -p "$(DESTDIR)/usr/lib/ponysay/"
|
mkdir -p "$(DESTDIR)/usr/lib/ponysay/"
|
||||||
install -s "ponysaytruncater" "$(DESTDIR)/usr/lib/ponysay/truncater"
|
install -s "ponysaytruncater" "$(DESTDIR)/usr/lib/ponysay/truncater"
|
||||||
install "ponysaylist.pl" "$(DESTDIR)/usr/lib/ponysay/list.pl"
|
install "ponysaylist.pl" "$(DESTDIR)/usr/lib/ponysay/list.pl"
|
||||||
|
install "ponysaylinklist.pl" "$(DESTDIR)/usr/lib/ponysay/linklist.pl"
|
||||||
|
|
||||||
mkdir -p "$(DESTDIR)/usr/share/bash-completion/completions/"
|
mkdir -p "$(DESTDIR)/usr/share/bash-completion/completions/"
|
||||||
install "completion/bash-completion.sh" "$(DESTDIR)/usr/share/bash-completion/completions/ponysay"
|
install "completion/bash-completion.sh" "$(DESTDIR)/usr/share/bash-completion/completions/ponysay"
|
||||||
|
@ -116,6 +117,7 @@ uninstall:
|
||||||
unlink "$(DESTDIR)/usr/bin/ponysay"
|
unlink "$(DESTDIR)/usr/bin/ponysay"
|
||||||
unlink "$(DESTDIR)/usr/bin/ponythink"
|
unlink "$(DESTDIR)/usr/bin/ponythink"
|
||||||
unlink "$(DESTDIR)/usr/lib/ponysay/list.pl"
|
unlink "$(DESTDIR)/usr/lib/ponysay/list.pl"
|
||||||
|
unlink "$(DESTDIR)/usr/lib/ponysay/linklist.pl"
|
||||||
unlink "$(DESTDIR)/usr/lib/ponysay/truncater"
|
unlink "$(DESTDIR)/usr/lib/ponysay/truncater"
|
||||||
unlink "$(DESTDIR)/usr/share/licenses/ponysay/COPYING"
|
unlink "$(DESTDIR)/usr/share/licenses/ponysay/COPYING"
|
||||||
unlink "$(DESTDIR)/usr/share/bash-completion/completions/ponysay"
|
unlink "$(DESTDIR)/usr/share/bash-completion/completions/ponysay"
|
||||||
|
|
80
ponysay
80
ponysay
|
@ -39,7 +39,11 @@ version() {
|
||||||
|
|
||||||
scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2`
|
scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2`
|
||||||
listcmd="${SCRIPTDIR}/../lib/ponysay/list.pl"
|
listcmd="${SCRIPTDIR}/../lib/ponysay/list.pl"
|
||||||
|
linklistcmd="${SCRIPTDIR}/../lib/ponysay/linklist.pl"
|
||||||
truncatercmd="${SCRIPTDIR}/../lib/ponysay/truncater"
|
truncatercmd="${SCRIPTDIR}/../lib/ponysay/truncater"
|
||||||
|
[[ -f "./ponysaylist.pl" ]] && listcmd="./ponysaylist.pl"
|
||||||
|
[[ -f "./ponysaylinklist.pl" ]] && linklistcmd="./ponysaylinklist.pl"
|
||||||
|
[[ -f "./ponysaytruncater" ]] && truncatercmd="./ponysaytruncater"
|
||||||
|
|
||||||
haspq=1
|
haspq=1
|
||||||
if [[ -f './pq4ps-list' ]]; then
|
if [[ -f './pq4ps-list' ]]; then
|
||||||
|
@ -87,75 +91,7 @@ _linklist() {
|
||||||
|
|
||||||
scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2`
|
scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2`
|
||||||
|
|
||||||
perl '/dev/stdin' $(echo $args) <<EOF | sed -e 's/ /_/g' > '/dev/shm/.ponysay~'
|
perl $listcmd $scrw $(perl $linklistcmd $(echo $args) | sed -e 's/ /_/g') | sed -e 's/_/ /g' | qlist
|
||||||
#!/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~'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
linklist() {
|
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)
|
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 > "/dev/shm/.ponythink"
|
cat <(echo -e $pcmd) $ccmd > "/tmp/.ponythink"
|
||||||
perl '/dev/shm/.ponythink' "$@"
|
perl '/tmp/.ponythink' "$@"
|
||||||
rm '/dev/shm/.ponythink'
|
rm '/tmp/.ponythink'
|
||||||
else
|
else
|
||||||
perl <(cat <(echo -e $pcmd) $ccmd) "$@"
|
perl <(cat <(echo -e $pcmd) $ccmd) "$@"
|
||||||
fi
|
fi
|
||||||
|
|
72
ponysaylinklist.pl
Executable file
72
ponysaylinklist.pl
Executable file
|
@ -0,0 +1,72 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
# ponysaylist
|
||||||
|
# Prints a list of ponies in columns
|
||||||
|
#
|
||||||
|
# Licensed under WTFPL
|
||||||
|
# See COPYING for details
|
||||||
|
|
||||||
|
# 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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue