From 532ab6c6ee1e529cc98e4d85cd27d5664d2752ac Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 18 Aug 2012 01:56:08 +0200 Subject: but i wasn't prepared for this --- pq4ps | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'pq4ps') diff --git a/pq4ps b/pq4ps index 513bcec..576a4e8 100755 --- a/pq4ps +++ b/pq4ps @@ -1,26 +1,24 @@ -#!/bin/bash +#!/usr/bin/env 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 +if [ $# == 1 ] && ([ "$1" == '-l' ] || [ "$1" == '--list' ]); then perl "$0.pl" "$INSTALLDIR" | cut -d @ -f 1 | uniq else _ponies="$(perl "$0.pl" "$INSTALLDIR")" ponies=() - if (( $# > 1 )); then + if (( $# > 0 )); then p=() for arg in "$@"; do - p+=( $(echo "$_ponies" | grep "^$arg@") ) + p+="$(echo "$_ponies" | grep "^$arg@") " done _ponies=$p fi - for _pony in $_ponies; do - ponies+=( $_pony ) - done + ponies=( $_ponies ) - if [[ ${#ponies[@]} == 0 ]]; then + if (( ${#ponies[@]} == 0 )); then ponies=() for arg in "$@"; do ponies+=( "$arg" ) -- cgit