1
0
Fork 0
mirror of synced 2024-12-12 18:35:46 -05:00

Escape space in YADM_HOOK_FULL_COMMAND (#187)

Backslashes are used to escape spaces, tabs, and backslashes. This
allows hooks to identify separate parameters (which are space
delimited).
This commit is contained in:
Tim Byrne 2020-01-23 08:11:19 -06:00
parent 3b820835ab
commit ccb75b97ea
No known key found for this signature in database
GPG key ID: 14DB4FC2465A4B12

11
yadm
View file

@ -70,7 +70,16 @@ function main() {
require_git
# capture full command, for passing to hooks
FULL_COMMAND="$*"
# the parameters will be space delimited and
# spaces, tabs, and backslashes will be escaped
_tab=$'\t'
for param in "$@"; do
param="${param//\\/\\\\}"
param="${param//$_tab/\\$_tab}"
param="${param// /\\ }"
_fc+=( "$param" )
done
FULL_COMMAND="${_fc[*]}"
# create the YADM_DIR if it doesn't exist yet
[ -d "$YADM_DIR" ] || mkdir -p "$YADM_DIR"