]> pd.if.org Git - zpackage/blobdiff - zpm-list
add missing newline
[zpackage] / zpm-list
index 471a2809a2e370f2372f7661cb326d1c089232a0..c10ace4ec1028b641fa25b95c3a022f89d5b8e4f 100755 (executable)
--- a/zpm-list
+++ b/zpm-list
@@ -4,28 +4,27 @@
 
 verbose=0
 nameonly=0
+latestonly=1
 
-while getopts :s:f:vn opt; do
+while getopts :s:f:vnI opt; do
        case $opt in
                f) pkgfile="$OPTARG" ;;
                s) status="$OPTARG" ;;
+               I) status=installed ;;
                v) verbose=1 ;;
                n) nameonly=1 ;;
+               a) latestonly=0 ;;
        esac
 done
 shift $(( OPTIND - 1))
 
-: ${pkgfile:=$ZPMDB}
+: ${pkgfile:=${ZPMDB:-/var/lib/zpm/local.db}}
 
 if [ -z "$pkgfile" ]; then
        echo "must specify package file"
        exit 1
 fi
 
-if [ -n "$status" ]; then
-       status=$(zpm quote "$status")
-fi
-
 if [ $nameonly -eq 0 ]; then
        cols="pkgid"
 else
@@ -37,15 +36,16 @@ if [ $verbose -eq 1 ]; then
 fi
 
 if [ -n "$status" ]; then
-       where="where status = '$status'"
+       status=$(zpm quote "$status")
+       where="and status = '$status'"
 fi
 
 pkgid=$1
 
 if [ -n "$pkgid" ]; then
        eval $(zpm parse -E "$pkgid")
-       if [ -n "$package" ]; then
-               package=$(zpm quote "$package")
+       if [ -n "$name" ]; then
+               package=$(zpm quote "$name")
                where="$where and package = '$package'"
        fi
        if [ -n "$version" ]; then
@@ -60,7 +60,10 @@ fi
 
 zpm shell $pkgfile <<EOS
 .separator "\t"
-select $cols from packages_pkgid $where
+select $cols from packages_pkgid where true $where
 ;
 EOS
 
+if [ $? -ne 0 ]; then
+       echo "select $cols from packages_pkgid where true $where" 1>&2
+fi