From 8d9dda24536e676d7d2199843e1b617971d0d3bf Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Sat, 4 Apr 2015 16:29:55 +0200 Subject: [PATCH] Issue #58: Fix the command execution under CLI --- lib/core.sh | 2 +- lib/util.sh | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/core.sh b/lib/core.sh index 8580c1e..eb89283 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -190,7 +190,7 @@ function _run_juju_with_proot(){ if [ "$1" != "" ] then - _run_proot "${proot_args}" "${@}" + insert_quotes "${@}" | _run_proot "${proot_args}" "${SH[@]}" else _run_proot "${proot_args}" "${SH[@]}" fi diff --git a/lib/util.sh b/lib/util.sh index 9f411a3..0322138 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -67,3 +67,14 @@ function ask(){ fi } + +function insert_quotes(){ +# It inserts quotes between arguments. +# Useful to preserve quotes on command +# to be used inside sh -c/bash -c + C='' + for i in "$@"; do + C="$C \"${i//\"/\\\"}\"" + done + echo ${C} +}