mirror of
https://github.com/TheLocehiliosan/yadm
synced 2024-10-27 20:34:27 +00: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:
parent
3b820835ab
commit
ccb75b97ea
11
yadm
11
yadm
@ -70,7 +70,16 @@ function main() {
|
|||||||
require_git
|
require_git
|
||||||
|
|
||||||
# capture full command, for passing to hooks
|
# 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
|
# create the YADM_DIR if it doesn't exist yet
|
||||||
[ -d "$YADM_DIR" ] || mkdir -p "$YADM_DIR"
|
[ -d "$YADM_DIR" ] || mkdir -p "$YADM_DIR"
|
||||||
|
Loading…
Reference in New Issue
Block a user