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