I have the following script in a .gitconfig alias:
[alias]
vx = "!f() { # I want to put a comment here \
foo='foo'; \
bar='bar'; \
separator=': '; \
# Comment Here As well \
result="${foo}${separator}${bar}"; \
echo $result; \
}; f"
If works fine if I remove the comments. However, with the comments the script just fails to run. Do comments inside a gitconfig alias use an operator different from #?
Run git config alias.vx and you will see the alias is printed as a long single line. You cannot insert a shell comment in the middle of a line — comments start with # and ends at end-of-line. Once bash sees # it ignores the rest of the line.
The only workaround I can think of is to insert dummy commands that contain quoted strings. Like : Text; (: is a no-op command in shells; see https://linux.die.net/man/1/bash, section "Shell Builtin Commands") or echo Comment >/dev/null;
[alias]
vx = "!f() { : I want to put a comment here; \
foo='foo'; \
bar='bar'; \
separator=': '; \
: Comment Here As well; \
result="${foo}${separator}${bar}"; \
echo $result; \
}; f"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With