diff options
author | root <root@pigstarter.de> | 2013-11-02 02:06:53 +0100 |
---|---|---|
committer | root <root@pigstarter.de> | 2013-11-02 02:06:53 +0100 |
commit | a1fc5b132349946dc9dc536de7a2f2812e407105 (patch) | |
tree | aaab586a9e002681301a3db2928a99a727fcb11c | |
parent | c88d66a0cbaa2baa258f212cb39fb940b86d2d30 (diff) |
require root for punani only when you actually do something
-rw-r--r-- | lib/punani | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -48,7 +48,7 @@ _punanidb_aptget_vim=vim _punani_resolve_package(){ : ${PACKER?PACKER is not set,bailing out} pkg=${1?please provide package name to resolve} - eval printf \"\${_punanidb_${PACKER_DB}_${pkg}-}\" | grep . + eval printf "%s" \"\${_punanidb_${PACKER}_${pkg}-}\" | grep . } _punani_aptget_install(){ apt-get -y install "$@" ;} _punani_aptget_remove(){ apt-get -y remove "$@" ;} @@ -64,12 +64,10 @@ _punani_brew_remove(){ brew remove "$@";} _punani_brew_has(){ error "not implemented"; return 1 ;} punani(){ - ! is_root && error "punani requires super-user rights" && return 1 ACTION="$1"; shift PKGS="$*" - PACKER_DB=$(printf ${PACKER}| sed 's/-//g') for p in apt-get pacman yum brew;do - exists "$p" && PACKER=`printf $p | sed 's/-//g'` && break + exists "$p" && PACKER=`printf "%s" "$p" | sed 's/-//g'` && break done [ -z "${PACKER:-}" ] && error "Error 2: no known package manager found; no punani for you!" && return 1 @@ -83,10 +81,12 @@ punani(){ case "$ACTION" in install) eval _punani_${PACKER}_has $RES && info "$RES already installed, skipping" && continue + ! is_root && error "punani requires super-user rights for installing" && return 1 eval _punani_${PACKER}_install $RES || error "cannot install $RES with $PACKER" ;; remove) ! eval _punani_${PACKER}_has $RES && info "$RES not installed, skipping" && continue + ! is_root && error "punani requires super-user rights for removing" && return 1 eval _punani_${PACKER}_remove $RES || error "cannot install $RES with $PACKER" ;; has) |