fix option string spacing issues, unquote them!

This commit is contained in:
Asif Bacchus 2020-03-26 05:37:03 -06:00
parent 91359306aa
commit bcb6c9c5ef
2 changed files with 15 additions and 7 deletions

View File

@ -4,15 +4,15 @@
"fsPath": "$ROOTPATH$/borghelper.sh",
"bookmarks": [
-1,
253,
151,
261,
159,
-1,
-1,
-1,
-1,
-1,
-1,
84
92
]
}
]

View File

@ -69,6 +69,14 @@ while [ $# -gt 0 ]; do
archiveName="$2"
shift
;;
--exclude)
# exclude files from restore
if [ -z "$2" ]; then
consoleError 1 "Please provide a list of exclusions in the proper borg format."
fi
exclusions="$2"
shift
;;
-f|--file)
# specific file to restore
if [ -z "$2" ]; then
@ -173,8 +181,8 @@ if [ "$fileName" ] && [ -z "$archiveName" ]; then
fi
# clean-up leading spaces in option strings
commonOptions=${commonOptions##[[:space:]]}
restoreOptions=${restoreOptions##[[:space:]]}
if [ "$commonOptions" ]; then commonOptions=${commonOptions##[[:space:]]}; fi
if [ "$restoreOptions" ]; then restoreOptions=${restoreOptions##[[:space:]]}; fi
### read borg information file
@ -256,11 +264,11 @@ elif [ "$operation" = 'restore' ]; then
if [ -z "$fileName" ]; then
# restore entire archive
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
borg --show-rc "$commonOptions" extract "$restoreOptions" ::"${archiveName}"
borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}"
elif [ "$fileName" ]; then
# restore single file
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
borg --show-rc "$commonOptions" extract "$restoreOptions" ::"${archiveName}" "${fileName}"
borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" "${fileName}"
fi
fi