From 3d068710a24574bbe581c703c79484f909275d82 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Tue, 21 Aug 2018 15:05:19 +0000 Subject: [PATCH] quote shell variables --- zpm-installed | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ zpm-ipkgfile | 10 ++++++---- 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100755 zpm-installed diff --git a/zpm-installed b/zpm-installed new file mode 100755 index 0000000..fe84874 --- /dev/null +++ b/zpm-installed @@ -0,0 +1,52 @@ +#!/bin/sh + +# show the installed version for each package if no arguments are given, all +# installed packages are displayed. + +chroot=1 +pkgroot= + +while getopts :R:CNXf:d:Dt:T:u:g: opt; do + case $opt in + R) pkgroot="$OPTARG" ;; + d) ZPMDB="$OPTARG" ;; + esac +done + +shift $((OPTIND - 1)) + +for cf in /etc/zpmrc ~/.zpmrc ./.zpmrc; do + test -r $cf && . $cf +done + +: ${ZPMDB:=/var/lib/zpm/db.zpm} + +export ZPMDB + +die() { + printf 'zpm-installed:' 1>&2 + printf ' %s' $* 1>&2 + printf '\n' 1>&2 + exit 1 +} + +db=$pkgroot$ZPMDB + +set -e +zpm test -v $db + +{ + + printf '.separator "\\t"\n' + printf 'select package,version,release from packages\n' +if [ $# -gt 0 ]; then + printf 'where package in\n(' + printf "'%s'" "$1" + shift + for pkg in "$@"; do + printf ",'%s'" "$pkg" + done + printf ')\n' +fi +printf ';\n' +} | zpm shell $db diff --git a/zpm-ipkgfile b/zpm-ipkgfile index 281fcca..15107d2 100755 --- a/zpm-ipkgfile +++ b/zpm-ipkgfile @@ -48,10 +48,9 @@ ZPMPKGFILE=$pkgfile export ZPMPKGFILE set -e -for path in $*; do - - name=$(basename -- $path) - dir=$(dirname -- $path) +for path in "$@"; do + name=$(basename -- "$path") + dir=$(dirname -- "$path") dir=${dir#/} if [ "$pkgroot" != '/' ]; then @@ -73,6 +72,9 @@ for path in $*; do : ${owner:=$(pkgfileinfo username $path)} : ${group:=$(pkgfileinfo groupname $path)} + # TODO if the file already exists, and is the correct + # hash or directory, do nothing + # can't use install because it's not posix. # probably worth writing a zpm-install, but with # a different name since that wants to be a package install -- 2.40.0