summaryrefslogtreecommitdiff
path: root/is_built
diff options
context:
space:
mode:
authorNicolás Reynolds <apoyosis@correo.inta.gob.ar>2011-12-22 23:27:22 -0300
committerNicolás Reynolds <apoyosis@correo.inta.gob.ar>2011-12-22 23:27:22 -0300
commitafeb8ee939f23256192239622f57265cf4c6cb4c (patch)
tree77676089022f2b1df8e34032d01a0a9ef0647c96 /is_built
parentf258090c62535b9e02450494507f2e3f08024c96 (diff)
parent32b6057b15e4f0872b9ebd51038c72b0d681cb80 (diff)
Merge branch 'master' of ssh://gparabola/libretools
Diffstat (limited to 'is_built')
-rwxr-xr-xis_built17
1 files changed, 15 insertions, 2 deletions
diff --git a/is_built b/is_built
index f789e4f..60f24e9 100755
--- a/is_built
+++ b/is_built
@@ -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