Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape backslash in fish shell with shellescape() #8810

Closed
wants to merge 1 commit into from
Closed

Escape backslash in fish shell with shellescape() #8810

wants to merge 1 commit into from

Conversation

jasonccox
Copy link
Contributor

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 in
Fish 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 be
treated as an escape character (echo '\a' prints \a). However, all
backslashes within single quotes can safely be escaped because two
consecutive backslashes always produce a single literal backslash
(echo '\\a' also prints \a).

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 in
Fish 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 be
treated as an escape character (`echo '\a'` prints `\a`). However, all
backslashes within single quotes can safely be escaped because two
consecutive backslashes always produce a single literal backslash
(`echo '\\a'` also prints `\a`).
@codecov
Copy link

codecov bot commented Aug 29, 2021

Codecov Report

Merging #8810 (729bf7a) into master (9aecf79) will decrease coverage by 87.69%.
The diff coverage is 0.00%.

❗ Current head 729bf7a differs from pull request most recent head 3155006. Consider uploading reports for the commit 3155006 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##           master    #8810       +/-   ##
===========================================
- Coverage   90.15%    2.46%   -87.70%     
===========================================
  Files         151      149        -2     
  Lines      170762   165514     -5248     
===========================================
- Hits       153949     4072   -149877     
- Misses      16813   161442   +144629     
Flag Coverage Δ
huge-clang-none ?
huge-gcc-none ?
huge-gcc-testgui ?
huge-gcc-unittests 2.46% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/buffer.c 3.46% <0.00%> (-88.99%) ⬇️
src/strings.c 26.85% <0.00%> (-69.41%) ⬇️
src/version.c 0.86% <ø> (-91.48%) ⬇️
src/float.c 0.00% <0.00%> (-99.22%) ⬇️
src/gui_gtk_f.c 0.00% <0.00%> (-97.54%) ⬇️
src/sound.c 0.00% <0.00%> (-97.12%) ⬇️
src/crypt_zip.c 0.00% <0.00%> (-97.06%) ⬇️
src/match.c 0.00% <0.00%> (-96.98%) ⬇️
src/sha256.c 0.00% <0.00%> (-96.94%) ⬇️
src/evalbuffer.c 0.00% <0.00%> (-96.92%) ⬇️
... and 140 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9dcd349...3155006. Read the comment docs.

@brammool brammool closed this in 6e82351 Aug 29, 2021
chrisbra pushed a commit to chrisbra/vim that referenced this pull request Aug 30, 2021
Problem:    Escaping for fish shell does not work properly.
Solution:   Insert a backslash before a backslash. (Jason Cox, closes vim#8810)
lewis6991 pushed a commit to lewis6991/neovim that referenced this pull request Dec 12, 2021
Problem:    Escaping for fish shell does not work properly.
Solution:   Insert a backslash before a backslash. (Jason Cox, closes vim/vim#8810)
vim/vim@6e82351
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant