From d86282b27b99dcfcadf0101007671d4b2ec392e7 Mon Sep 17 00:00:00 2001 From: Ralf Zerres Date: Mon, 25 Jun 2018 19:59:43 +0200 Subject: [PATCH] dsnap-sync: args parser - prepare arguments as string for ssh call --- bin/dsnap-sync | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bin/dsnap-sync b/bin/dsnap-sync index ca69314..a9276ee 100755 --- a/bin/dsnap-sync +++ b/bin/dsnap-sync @@ -50,6 +50,7 @@ BTRFS_PIPE=$TMPDIR_PIPE/btrfs.out exec 3>$PIPE 4>$BTRFS_PIPE # global variables +args= donotify=0 answer=no disk_count=-1 @@ -128,6 +129,23 @@ check_snapper_failed_ids () { fi } +quote_args () { + # quote command in ssh call to prevent remote side from expanding any arguments + # using dash's buildin printf + + args= + if [ $# -gt 0 ]; then + # no need to make COMMAND an array - ssh will merge it anyway + COMMAND= + while [ $# -gt 0 ]; do + arg=$(printf "%s" "$1") + COMMAND="${COMMAND}${arg} " + shift + done + args="${args}${COMMAND}" + fi +} + set_snapper_target_config () { local snapper_config=$1 local snapper_config_tpye='none'