From 70c27ca36f696b12012d7f47ac3071f747b95207 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 1 Aug 2012 03:33:30 +0200 Subject: some edits --- pq4ps | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'pq4ps') 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 -- cgit