diff options
author | Sven-Hendrik Haase <sh@lutzhaase.com> | 2012-02-26 18:28:03 +0100 |
---|---|---|
committer | Sven-Hendrik Haase <sh@lutzhaase.com> | 2012-02-26 18:28:03 +0100 |
commit | 378e39d90c0f8a70eebf1edb18a9ba525a776572 (patch) | |
tree | 8caff7e655dea1b65b1d53869483f9b7c3c0585c /ponysay | |
parent | 3243bdff928a3fb9aebeaf503033b29f726b5af4 (diff) | |
download | ponysay-378e39d90c0f8a70eebf1edb18a9ba525a776572.tar.gz ponysay-378e39d90c0f8a70eebf1edb18a9ba525a776572.tar.bz2 ponysay-378e39d90c0f8a70eebf1edb18a9ba525a776572.zip |
Make proper all the things ಠ_ರೃ
Diffstat (limited to 'ponysay')
-rwxr-xr-x | ponysay | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -1,23 +1,33 @@ #!/usr/bin/env bash export PERL_UNICODE=S -ponydir=$PWD/ponies +[[ -z ${PONYDIR} ]] && PONYDIR=/usr/share/ponies +HOMEDIR=${HOME}/.ponies + +cmd=cowsay +[[ ${0} == *ponythink ]] && cmd=cowthink function ponyf() { - if [[ -f ${ponydir}/${1}.cow ]] ; then - cowsay -f "${ponydir}/${1}.cow" $@ + if [[ -f ${HOMEDIR}/${1}.cow ]]; then + ${cmd} -f "${HOMEDIR}/${1}.cow" $@ + elif [[ -f ${PONYDIR}/${1}.cow ]]; then + ${cmd} -f "${PONYDIR}/${1}.cow" $@ else ponyr $@ fi } 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 do case ${OPT} in - v) echo "v0.01" ; exit;; + v) echo "v0.1" ; exit;; h) echo "helpherpderp" ; exit;; f) ponyf $* ; exit;; \?) echo "DERP"; exit;; |