aboutsummaryrefslogtreecommitdiff
path: root/pq4ps
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-08-01 03:33:30 +0200
committerMattias Andrée <maandree@operamail.com>2012-08-01 03:33:30 +0200
commit70c27ca36f696b12012d7f47ac3071f747b95207 (patch)
tree7fd090244f918246f179becb767511fc8afc26fd /pq4ps
parente5b783e52858ae73d26c21464952323b9e3f320a (diff)
downloadponysay-70c27ca36f696b12012d7f47ac3071f747b95207.tar.gz
ponysay-70c27ca36f696b12012d7f47ac3071f747b95207.tar.bz2
ponysay-70c27ca36f696b12012d7f47ac3071f747b95207.zip
some edits
Diffstat (limited to 'pq4ps')
-rwxr-xr-xpq4ps14
1 files changed, 8 insertions, 6 deletions
diff --git a/pq4ps b/pq4ps
index 433f062..ace4a30 100755
--- a/pq4ps
+++ b/pq4ps
@@ -1,15 +1,17 @@
#!/bin/bash
+INSTALLDIR="$(dirname "$(dirname "$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )")")" # Get main bash script directory's parent
+
if [[ $# == 1 ]] && [[ "$1" == '-l' || "$1" == '--list' ]]; then
- perl $0.pl | cut -d @ -f 1 | uniq
+ perl "$0.pl" "$INSTALLDIR" | cut -d @ -f 1 | uniq
else
- _ponies="$(perl $0.pl)"
+ _ponies="$(perl "$0.pl" "$INSTALLDIR")"
ponies=()
- if [[ ! $# == 0 ]]; then
- p=""
+ if (( $# > 1 )); then
+ p=()
for arg in "$@"; do
- p=$p$(echo "$_ponies" | grep "^$arg@")" "
+ p+=( $(echo "$_ponies" | grep "^$arg@") )
done
_ponies=$p
fi
@@ -32,7 +34,7 @@ else
p="$(echo $pony | cut -d '@' -f 1)"
f="$(echo $pony | cut -d '@' -f 2)"
- q="$(cat "/usr/share/ponysay/quotes/$f")"
+ q="$(cat "$INSTALLDIR/share/ponysay/quotes/$f")"
echo "-f" $p $q
fi