Escape backslash in fish shell with shellescape() #8810
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fish shell uses backslash as an escape character in single quotes, so
the backslash must be escaped in order to produce a literal backslash.
This change modifies the
shellescape()
function to escape backslash inFish shell only.
Note that Fish's backslash behavior is a bit odd in that it does what it
thinks you mean. Only
'
really needs to be escaped (echo '\''
prints'
), so if the backslash precedes other characters, it will not betreated as an escape character (
echo '\a'
prints\a
). However, allbackslashes within single quotes can safely be escaped because two
consecutive backslashes always produce a single literal backslash
(
echo '\\a'
also prints\a
).