Make proper all the things ಠ_ರೃ

This commit is contained in:
Sven-Hendrik Haase 2012-02-26 18:28:03 +01:00
parent 3243bdff92
commit 378e39d90c
2 changed files with 15 additions and 32 deletions

20
ponysay
View file

@ -1,23 +1,33 @@
#!/usr/bin/env bash #!/usr/bin/env bash
export PERL_UNICODE=S export PERL_UNICODE=S
ponydir=$PWD/ponies [[ -z ${PONYDIR} ]] && PONYDIR=/usr/share/ponies
HOMEDIR=${HOME}/.ponies
cmd=cowsay
[[ ${0} == *ponythink ]] && cmd=cowthink
function ponyf() { function ponyf() {
if [[ -f ${ponydir}/${1}.cow ]] ; then if [[ -f ${HOMEDIR}/${1}.cow ]]; then
cowsay -f "${ponydir}/${1}.cow" $@ ${cmd} -f "${HOMEDIR}/${1}.cow" $@
elif [[ -f ${PONYDIR}/${1}.cow ]]; then
${cmd} -f "${PONYDIR}/${1}.cow" $@
else else
ponyr $@ ponyr $@
fi fi
} }
function ponyr() { function ponyr() {
cowsay -f $(ls ${ponydir}/*.cow | sort -R | head -n1) $@ if [[ -d ${HOMEDIR} ]] && [[ -n $(find ${HOMEDIR} -name \*.cow) ]]; then
${cmd} -f $(ls ${HOMEDIR}/*.cow | sort -R | head -n1) $@
elif [[ -d ${PONYDIR} ]] && [[ -n $(find ${PONYDIR} -name \*.cow) ]]; then
${cmd} -f $(ls ${PONYDIR}/*.cow | sort -R | head -n1) $@
fi
} }
while getopts f:hv OPT while getopts f:hv OPT
do do
case ${OPT} in case ${OPT} in
v) echo "v0.01" ; exit;; v) echo "v0.1" ; exit;;
h) echo "helpherpderp" ; exit;; h) echo "helpherpderp" ; exit;;
f) ponyf $* ; exit;; f) ponyf $* ; exit;;
\?) echo "DERP"; exit;; \?) echo "DERP"; exit;;

View file

@ -1,27 +0,0 @@
#!/usr/bin/env bash
export PERL_UNICODE=S
ponydir=$PWD/ponies
function ponyf() {
if [[ -f ${ponydir}/${1}.cow ]] ; then
cowthink -f "${ponydir}/${1}.cow" $@
else
ponyr $@
fi
}
function ponyr() {
cowthink -f $(ls ${ponydir}/*.cow | sort -R | head -n1) $@
}
while getopts f:hv OPT
do
case ${OPT} in
v) echo "v0.01" ; exit;;
h) echo "helpherpderp" ; exit;;
f) ponyf $* ; exit;;
\?) echo "DERP"; exit;;
*) ponyr $* ; exit;;
esac
done
ponyr $*