Hi Kairui,
On Thu, 19 Aug 2021 19:39:11 +0800
Kairui Song <kasong(a)redhat.com> wrote:
For storing arguments, plain string is not a good choice. Array is
preferred:
See:
https://github.com/koalaman/shellcheck/wiki/SC2086 ^^^^^^
SC2089 like in
patch 9?
Thanks
Philipp
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
mkdumprd | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index de4e9944..2b0ccca4 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -111,20 +111,20 @@ get_ssh_size() {
mkdir_save_path_ssh()
{
local _opt _dir
- _opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes"
- ssh -qn $_opt $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null
+ _opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o
StrictHostKeyChecking=yes)
+ ssh -qn "${_opt[@]}" $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null
_ret=$?
if [ $_ret -ne 0 ]; then
perror_exit "mkdir failed on $1:$SAVE_PATH"
fi
#check whether user has write permission on $1:$SAVE_PATH
- _dir=$(ssh -qn $_opt $1 mktemp -dqp $SAVE_PATH 2>/dev/null)
+ _dir=$(ssh -qn "${_opt[@]}" $1 mktemp -dqp $SAVE_PATH 2>/dev/null)
_ret=$?
if [ $_ret -ne 0 ]; then
perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make
sure user has write permission on destination"
fi
- ssh -qn $_opt $1 rmdir $_dir
+ ssh -qn "${_opt[@]}" $1 rmdir $_dir
return 0
}