mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-22 12:27:59 +01:00
Removed some weird echos and reindeted the full file
This commit is contained in:
parent
f404ab48d7
commit
e48e73ef4b
1 changed files with 164 additions and 161 deletions
63
ponysay
63
ponysay
|
@ -19,14 +19,15 @@ else
|
||||||
cmd="$PONYSAY_COWSAY"
|
cmd="$PONYSAY_COWSAY"
|
||||||
customcmd=1
|
customcmd=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ ${0} == *ponythink ]] &&
|
[[ ${0} == *ponythink ]] &&
|
||||||
if [[ "$PONYSAY_COWTHINK" = "" ]]; then
|
if [[ "$PONYSAY_COWTHINK" = "" ]]; then
|
||||||
cmd=cowthink
|
cmd=cowthink
|
||||||
customcmd=0
|
customcmd=0
|
||||||
else
|
else
|
||||||
cmd="$PONYSAY_COWTHINK"
|
cmd="$PONYSAY_COWTHINK"
|
||||||
customcmd=1
|
customcmd=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version() {
|
version() {
|
||||||
echo "ponysay v$version"
|
echo "ponysay v$version"
|
||||||
|
@ -38,17 +39,17 @@ truncatercmd="${SCRIPTDIR}/../lib/ponysay/truncater"
|
||||||
|
|
||||||
haspq=1
|
haspq=1
|
||||||
if [[ -f './pq4ps-list' ]]; then
|
if [[ -f './pq4ps-list' ]]; then
|
||||||
function qlist
|
function qlist {
|
||||||
{ ./pq4ps-list
|
./pq4ps-list
|
||||||
}
|
}
|
||||||
elif [[ -f '/usr/bin/pq4ps-list' ]]; then
|
elif [[ -f '/usr/bin/pq4ps-list' ]]; then
|
||||||
function qlist
|
function qlist {
|
||||||
{ /usr/bin/pq4ps-list
|
/usr/bin/pq4ps-list
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
haspq=0
|
haspq=0
|
||||||
function qlist
|
function qlist {
|
||||||
{ cat
|
cat
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -70,11 +71,13 @@ _linklist() {
|
||||||
|
|
||||||
for file in $files; do
|
for file in $files; do
|
||||||
target=$(readlink $1"/"$file".pony")
|
target=$(readlink $1"/"$file".pony")
|
||||||
|
|
||||||
if [[ $target = "" ]]; then
|
if [[ $target = "" ]]; then
|
||||||
target=$file
|
target=$file
|
||||||
else
|
else
|
||||||
target=$(echo $target | sed -e 's/^\.\///g' -e 's/\.pony$//g')
|
target=$(echo $target | sed -e 's/^\.\///g' -e 's/\.pony$//g')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
args=$(echo $args $file $target)
|
args=$(echo $args $file $target)
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -153,6 +156,7 @@ EOF
|
||||||
|
|
||||||
linklist() {
|
linklist() {
|
||||||
_linklist $SYSTEMPONIES
|
_linklist $SYSTEMPONIES
|
||||||
|
|
||||||
if [[ -d $HOMEPONIES ]]; then
|
if [[ -d $HOMEPONIES ]]; then
|
||||||
_linklist $HOMEPONIES
|
_linklist $HOMEPONIES
|
||||||
fi
|
fi
|
||||||
|
@ -173,12 +177,14 @@ Options:
|
||||||
-l List pony files.
|
-l List pony files.
|
||||||
-L List pony files with synonyms inside brackets.
|
-L List pony files with synonyms inside brackets.
|
||||||
EOF
|
EOF
|
||||||
if [[ $haspq = 1 ]]; then
|
|
||||||
|
if [[ $haspq = 1 ]]; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
-q Use the pony quote feature.
|
-q Use the pony quote feature.
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
cat <<EOF
|
|
||||||
|
cat <<EOF
|
||||||
-f[name] Select a pony (either a file name or a pony name.)
|
-f[name] Select a pony (either a file name or a pony name.)
|
||||||
-W[column] The screen column where the message should be wrapped.
|
-W[column] The screen column where the message should be wrapped.
|
||||||
|
|
||||||
|
@ -200,8 +206,7 @@ say() {
|
||||||
echo -ne '\e[H\e[2J'
|
echo -ne '\e[H\e[2J'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function wtrunc
|
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' ]; then
|
||||||
cat
|
cat
|
||||||
else
|
else
|
||||||
|
@ -213,22 +218,20 @@ say() {
|
||||||
if [ "$PONYSAY_SHELL_LINES" = "" ]; then
|
if [ "$PONYSAY_SHELL_LINES" = "" ]; then
|
||||||
PONYSAY_SHELL_LINES=2
|
PONYSAY_SHELL_LINES=2
|
||||||
fi
|
fi
|
||||||
function htrunchead
|
|
||||||
{
|
function htrunchead {
|
||||||
head --lines=$(( `stty size <&2 | cut -d ' ' -f 1` - $PONYSAY_SHELL_LINES ))
|
head --lines=$(( `stty size <&2 | cut -d ' ' -f 1` - $PONYSAY_SHELL_LINES ))
|
||||||
}
|
}
|
||||||
function htrunctail
|
|
||||||
{
|
function htrunctail {
|
||||||
tail --lines=$(( `stty size <&2 | cut -d ' ' -f 1` - $PONYSAY_SHELL_LINES ))
|
tail --lines=$(( `stty size <&2 | cut -d ' ' -f 1` - $PONYSAY_SHELL_LINES ))
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $customcmd = 0 ]]; then
|
if [[ $customcmd = 0 ]]; then
|
||||||
function cowcmd
|
function cowcmd {
|
||||||
{
|
|
||||||
echo "standrd $cmd"
|
|
||||||
pcmd='#!/usr/bin/perl\nuse utf8;'
|
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)
|
||||||
echo "is $cmd"
|
|
||||||
if [[ ${0} == *ponythink ]]; then
|
if [[ ${0} == *ponythink ]]; then
|
||||||
cat <(echo -e $pcmd) $ccmd > "/dev/shm/.ponythink"
|
cat <(echo -e $pcmd) $ccmd > "/dev/shm/.ponythink"
|
||||||
perl '/dev/shm/.ponythink' "$@"
|
perl '/dev/shm/.ponythink' "$@"
|
||||||
|
@ -238,8 +241,7 @@ say() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
function cowcmd
|
function cowcmd {
|
||||||
{
|
|
||||||
echo "custom $cmd"
|
echo "custom $cmd"
|
||||||
$cmd "$@"
|
$cmd "$@"
|
||||||
}
|
}
|
||||||
|
@ -262,9 +264,9 @@ opts="f:W:Llhv"
|
||||||
if [[ $haspq ]]; then
|
if [[ $haspq ]]; then
|
||||||
opts=$opts"q"
|
opts=$opts"q"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
usepq=0
|
usepq=0
|
||||||
while getopts $opts OPT
|
while getopts $opts OPT; do
|
||||||
do
|
|
||||||
case ${OPT} in
|
case ${OPT} in
|
||||||
v) version; exit ;;
|
v) version; exit ;;
|
||||||
h) usage; exit ;;
|
h) usage; exit ;;
|
||||||
|
@ -280,12 +282,12 @@ shift $((OPTIND - 1))
|
||||||
|
|
||||||
if [[ $usepq = 1 ]]; then
|
if [[ $usepq = 1 ]]; then
|
||||||
if [[ -f './pq4ps' ]]; then
|
if [[ -f './pq4ps' ]]; then
|
||||||
function q
|
function q {
|
||||||
{ ./pq4ps $@
|
./pq4ps $@
|
||||||
}
|
}
|
||||||
elif [[ -f '/usr/bin/pq4ps' ]]; then
|
elif [[ -f '/usr/bin/pq4ps' ]]; then
|
||||||
function q
|
function q {
|
||||||
{ /usr/bin/pq4ps $@
|
/usr/bin/pq4ps $@
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
$0 ${wrap:+-W$wrap} $(q "$*")
|
$0 ${wrap:+-W$wrap} $(q "$*")
|
||||||
|
@ -329,3 +331,4 @@ if [[ -n "$*" ]]; then
|
||||||
else
|
else
|
||||||
say
|
say
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue