diff options
author | Joshua Ismael Haase Hernández <hahj87@gmail.com> | 2011-12-21 01:14:32 -0600 |
---|---|---|
committer | Joshua Ismael Haase Hernández <hahj87@gmail.com> | 2011-12-21 01:14:32 -0600 |
commit | dce177d9f929c18d5eb2b5164b18f92c701a0052 (patch) | |
tree | a184d2959a12eac3b511f668526012867473b66f | |
parent | 6a56fa9179e7ce08b5bbaf4407c0d1a10aabde08 (diff) |
Some usage messages added
-rw-r--r-- | AUTHORS | 2 | ||||
-rwxr-xr-x | is_built | 17 | ||||
-rwxr-xr-x | toru | 12 |
3 files changed, 26 insertions, 5 deletions
@@ -1,2 +1,2 @@ -Joshua Ismael +Joshua Haase Nicolás Reynolds @@ -1,11 +1,24 @@ #!/bin/bash -# Detect is a package is installed or in a database +usage() { + echo "$0 " + echo + echo "Detect is a package is installed or in a database" + echo + echo "Example usage: is_built \"pcre>=20\"" +} + +while getopts 'h' arg; do + case $arg in + h) usage; exit 0 ;; + *) usage; exit 1 ;; + esac +done # Checks for package, if -T returns non-zero output, egrep will return 0 # because it finds it, so we negate the value to say it's not built. # -Sp works backwards, it will print output only when the package already # exists -# Example usage: is_built "pcre>=20" + !(sudo pacman -T "$1" | egrep "*" >/dev/null) || \ sudo pacman -Sp "$1" --print-format "%n-%v" 2>/dev/null | egrep "*" >/dev/null @@ -15,9 +15,17 @@ source /etc/abs.conf source /etc/libretools.conf +# TODO: clean usage instructions +function usage { + echo "$0 [options] repo1 ... repon" + echo + echo "-h : this message" + exit 1 +} + if [ ! -w "$TORUPATH" ]; then error "Toru's path isn't writable. Please check $TORUPATH" - exit 1 + exit 1 fi # TODO move to common functions @@ -115,7 +123,7 @@ split_pkgname_from_pkgver() { sed "s/^\(.\+\)-\([^-]\+-[^-]\+\)$/\1 \2/" $1 } -# Get the fullpkgver +# Get the fullpkgver # pkgname from pkgver separator can be either '-' or ' ' extract_fullpkgver() { echo "$@" | tr " " "\n" | sed "s/^.\+[ -]\([^-]\+-[^-]\+\)$/\1/" |