Commit 11178060 authored by Vitaly Lipatov's avatar Vitaly Lipatov

esu: add support for quoted args (with spaces)

parent 4252744e
...@@ -74,11 +74,30 @@ fi ...@@ -74,11 +74,30 @@ fi
set_pm_type set_pm_type
escape_args()
{
local output=''
while [ -n "$1" ] ; do
if has_space "$1" ; then
[ -n "$output" ] && output="$output '$1'" || output="'$1'"
else
[ -n "$output" ] && output="$output $1" || output="$1"
fi
shift
done
echo "$output"
}
escaped="$(escape_args "$@")"
# sudo is not accessible, will ask root password # sudo is not accessible, will ask root password
if ! set_sudo ; then if ! set_sudo ; then
#info "Enter root password:" #info "Enter root password:"
if [ -n "$*" ] ; then if [ -n "$*" ] ; then
exec su - -c "$@" [ -n "$quiet" ] || showcmd "su - -c $escaped"
exec su - -c "$escaped"
else else
# just shell # just shell
showcmd "su -" showcmd "su -"
...@@ -88,8 +107,8 @@ fi ...@@ -88,8 +107,8 @@ fi
#info "You can be asked about your password:" #info "You can be asked about your password:"
if [ -n "$*" ] ; then if [ -n "$*" ] ; then
[ -n "$quiet" ] || showcmd "$SUDO su - -c $*" [ -n "$quiet" ] || showcmd "$SUDO su - -c $escaped"
$SUDO su - -c "$@" $SUDO su - -c "$escaped"
else else
showcmd "$SUDO su -" showcmd "$SUDO su -"
$SUDO su - $SUDO su -
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment