aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rwxr-xr-xponysay21
2 files changed, 20 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index a0e8e88..9431e87 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,5 @@
-ponydir=/usr/share/ponies/
-scripts=ponysay ponythink
-bindir=/usr/bin/
install:
- mkdir $(ponydir)
- cp -r ponies $(ponydir)
- cp $(scripts) $(bindir)
+ mkdir -p $(DESTDIR)/usr/share/ponies
+ cp -r ponies/*.cow $(DESTDIR)/usr/share/ponies/
+ install -Dm755 ponysay $(DESTDIR)/usr/bin/ponysay
+ ln -s ponysay $(DESTDIR)/usr/bin/ponythink
diff --git a/ponysay b/ponysay
index 0f81fc5..ddaf7d0 100755
--- a/ponysay
+++ b/ponysay
@@ -1,22 +1,33 @@
#!/usr/bin/env bash
export PERL_UNICODE=S
-ponydir=/usr/share/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;;