but i wasn't prepared for this

This commit is contained in:
Mattias Andrée 2012-08-18 01:56:08 +02:00
parent 65409b446b
commit 532ab6c6ee
3 changed files with 14 additions and 16 deletions

14
ponysay
View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION=1.4 VERSION=1.4.1
@ -90,7 +90,7 @@ _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')
@ -114,7 +114,7 @@ linklist() {
# Pony quotes # Pony quotes
ponyquotes() { ponyquotes() {
[ "$TERM" = "-linux-" ] && TERM="linux" [ "$TERM" = "-linux-" ] && TERM="linux"
"$0" ${wrap:+-W$wrap} $("$quotecmd" "$*") "$0" ${wrap:+-W$wrap} $("$quotecmd" $@)
} }
# Usage help print function # Usage help print function
@ -146,7 +146,7 @@ say() {
export PERL_UNICODE=S export PERL_UNICODE=S
# Clear screen in TTY # Clear screen in TTY
( [ "$TERM" = "linux" ] || [ "$TERM" = "-linux-" ]) && echo -ne '\e[H\e[2J' ( [ "$TERM" = "linux" ] || [ "$TERM" = "-linux-" ] ) && echo -ne '\e[H\e[2J'
# Set PONYSAY_SHELL_LINES to default if not specified # Set PONYSAY_SHELL_LINES to default if not specified
[ "$PONYSAY_SHELL_LINES" = "" ] && PONYSAY_SHELL_LINES=2 [ "$PONYSAY_SHELL_LINES" = "" ] && PONYSAY_SHELL_LINES=2
@ -156,7 +156,7 @@ say() {
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
if [[ -f $truncatercmd ]]; then if [ -f $truncatercmd ]; then
$truncatercmd $scrw $truncatercmd $scrw
else else
cat cat
@ -220,7 +220,7 @@ say() {
# If no stdin and no arguments then print usage and exit # If no stdin and no arguments then print usage and exit
if [ -t 0 && $# == 0 ]; then if [ -t 0 ] && [ $# == 0 ]; then
usage usage
exit exit
fi fi
@ -236,7 +236,7 @@ while getopts "f:W:Llhvq" OPT; do
l) list; exit ;; l) list; exit ;;
L) linklist; exit ;; L) linklist; exit ;;
W) wrap="$OPTARG" ;; W) wrap="$OPTARG" ;;
q) ponyquotes; exit ;; q) shift $((OPTIND - 1)); ponyquotes "$*"; exit ;;
\?) usage >&2; exit 1 ;; \?) usage >&2; exit 1 ;;
esac esac
done done

14
pq4ps
View file

@ -1,26 +1,24 @@
#!/bin/bash #!/usr/bin/env bash
INSTALLDIR="$(dirname "$(dirname "$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )")")" # Get main bash script directory's parent INSTALLDIR="$(dirname "$(dirname "$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )")")" # Get main bash script directory's parent
if [ $# == 1 ] && [ "$1" == '-l' || "$1" == '--list' ]; then if [ $# == 1 ] && ([ "$1" == '-l' ] || [ "$1" == '--list' ]); then
perl "$0.pl" "$INSTALLDIR" | cut -d @ -f 1 | uniq perl "$0.pl" "$INSTALLDIR" | cut -d @ -f 1 | uniq
else else
_ponies="$(perl "$0.pl" "$INSTALLDIR")" _ponies="$(perl "$0.pl" "$INSTALLDIR")"
ponies=() ponies=()
if (( $# > 1 )); then if (( $# > 0 )); then
p=() p=()
for arg in "$@"; do for arg in "$@"; do
p+=( $(echo "$_ponies" | grep "^$arg@") ) p+="$(echo "$_ponies" | grep "^$arg@") "
done done
_ponies=$p _ponies=$p
fi fi
for _pony in $_ponies; do ponies=( $_ponies )
ponies+=( $_pony )
done
if [[ ${#ponies[@]} == 0 ]]; then if (( ${#ponies[@]} == 0 )); then
ponies=() ponies=()
for arg in "$@"; do for arg in "$@"; do
ponies+=( "$arg" ) ponies+=( "$arg" )

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
cmd="$(echo "$0" | sed -e 's/\-list$//g')" cmd="$(echo "$0" | sed -e 's/\-list$//g')"
pl="$0.pl" pl="$0.pl"