From 11e059255e52892cabe2ba4179ef832f42a37bf4 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Mon, 19 Nov 2018 01:44:13 +0000 Subject: [PATCH] add -g option to pathmod to take paths as globs --- zpm-pathmod | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/zpm-pathmod b/zpm-pathmod index 0a699fd..90c29c1 100755 --- a/zpm-pathmod +++ b/zpm-pathmod @@ -24,13 +24,22 @@ die() { pkgfile=${ZPMDB:-/var/lib/zpm/db.zpm} -while getopts f: opt; do +pathglob=0 + +while getopts f:g opt; do case $opt in f) pkgfile="$OPTARG" ;; + g) pathglob=1 ;; esac done shift $((OPTIND - 1)) +if [ $pathglob -eq 1 ]; then + pathop='glob' +else + pathop='=' +fi + set -e if [ ! -f $pkgfile ]; then @@ -94,7 +103,7 @@ while [ $# -gt 0 ]; do fi if [ $field = delete ]; then - printf "delete from packagefiles_pkgid where pkgid = '%s' and path = '%s';\n" "$pkgid" "$path" + printf "delete from packagefiles_pkgid where pkgid = '%s' and path $pathop '%s';\n" "$pkgid" "$path" else vfield=$(zpm quote "$field") @@ -107,7 +116,7 @@ while [ $# -gt 0 ]; do field=$(zpm quote -i "$field") if [ $show -eq 1 ]; then - printf "select %s from packagefiles_pkgid where pkgid = '%s' and path='$path';\n" "$field" "$pkgid" + printf "select %s from packagefiles_pkgid where pkgid = '%s' and path $pathop '$path';\n" "$field" "$pkgid" continue fi @@ -117,7 +126,7 @@ while [ $# -gt 0 ]; do value=$(zpm quote -q "$value") fi - printf "update packagefiles_pkgid set %s = %s where pkgid = '$pkgid' and path='$path';\n" $field $value + printf "update packagefiles_pkgid set %s = %s where pkgid = '$pkgid' and path $pathop '$path';\n" $field $value fi done -- 2.40.0