Fix root check

This commit is contained in:
zawz 2020-03-09 14:25:27 +01:00
parent 5be2abe9cc
commit 1c3d5d2dcf
3 changed files with 7 additions and 5 deletions

View file

@ -1,6 +1,9 @@
#!/bin/sh #!/bin/sh
[ -z "$opt_f" ] && root_check || exit 10 if [ -z "$opt_f" ] ; then
root_check || exit 10
fi
if [ -n "$1" ] if [ -n "$1" ]
then then
@ -88,7 +91,6 @@ then
then then
echo "No package specified" > /dev/stderr echo "No package specified" > /dev/stderr
else else
root_check
shift 1 shift 1
for I in $* for I in $*
do do

View file

@ -29,7 +29,7 @@ root_check()
if [ "$(id | cut -d'=' -f2 | cut -d'(' -f1)" -eq 0 ] if [ "$(id | cut -d'=' -f2 | cut -d'(' -f1)" -eq 0 ]
then then
echo "Cannot run as root" > /dev/stderr echo "Cannot run as root" > /dev/stderr
return $1 return 1
fi fi
return 0 return 0
} }

View file

@ -12,7 +12,7 @@ resolve_packages()
cd "$PKG_PATH" cd "$PKG_PATH"
for I in $* for I in $*
do do
if ! grep -wq "^$I" pkglist if ! grep -wq "^$I" pkglist 2>/dev/null
then then
[ "$LOG" = "true" ] && echo "Package '$I' not found" > /dev/stderr [ "$LOG" = "true" ] && echo "Package '$I' not found" > /dev/stderr
RET=1 RET=1
@ -38,7 +38,7 @@ resolve_deps()
is_installed() is_installed()
{ {
cd "$PKG_PATH" cd "$PKG_PATH"
grep -qw "^$1" installed grep -qw "^$1" installed 2>/dev/null
return $? return $?
} }