terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Escape single quotes for WSL

Open a4lg opened this issue 1 year ago • 4 comments

Summary of the Pull Request

This commit escapes single quotes ' (allowed in the Win32 subsystem) with '\'' (finish quote, print a single quote then begin quote again), which is a valid escape in the context of the POSIX shell, when a file/folder is dropped to a WSL tab.

Note: '"'"' on the first submission of this PR.

References and Relevant Issues

  • #18006
  • #16214

Detailed Description of the Pull Request / Additional comments

This is a follow-up of #16214 and fixes #18006.

Validation Steps Performed

PR Checklist

  • [x] Closes #18006
  • [ ] Tests added/passed
  • [ ] Documentation updated
    • If checked, please file a pull request on our docs repo and link it here: #xxx
  • [ ] Schema updated (if necessary)

a4lg avatar Oct 08 '24 06:10 a4lg

@microsoft-github-policy-service agree

a4lg avatar Oct 08 '24 06:10 a4lg

Would it be simpler to paste with double quotes and handle escaping of significant characters like $, ', or " with backspaces?

lhecker avatar Oct 08 '24 09:10 lhecker

@lhecker I would prefer searching for just one character ('), not three (three you mentioned minus ' plus backquote) I guess. Plus, single quote approach makes making mistakes or shell-dependent sequences almost impossible.

The inserting sequence '"'"' is odd (I have to admit) but in both quote cases (double and single), we would not escape so frequently.

a4lg avatar Oct 08 '24 11:10 a4lg

Also, escaping just like @sh formatting logic in jq seems simpler. Will change:

Old: '"'"' New: '\''

Additional references:

  1. POSIX Shell & Utilities: 2.2 Quoting
  2. POSIX Shell & Utilities: 2.2.1 Escape Character (Backslash)
  3. jq 1.7 Manual: Format strings and escaping (Examples)

a4lg avatar Oct 08 '24 23:10 a4lg

Hey, sorry about this - I didn't realize we had an open PR in this area when I changed how path translation works. You will probably have conflicts or outright failures once you merge main because isWSL has moved to a farm upstate.

DHowett avatar Nov 18 '24 21:11 DHowett

@DHowett I see. I'll check the code again and resubmit the new version later (if #18006 is remaining).

a4lg avatar Nov 22 '24 09:11 a4lg

Checked. Surprisingly, there's no merge conflicts... but fails to compile due to the lost isWSL variable.

The solution seems to be simple and working on it.

a4lg avatar Nov 22 '24 09:11 a4lg

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

Unrecognized words (1)

occured

Previously acknowledged words that are now absent barbaz Ralph stb 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:a4lg/terminal.git repository on the wsl-escape-single-quotes branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/11974465747/attempts/1'
Available :books: dictionaries could cover words (expected and unrecognized) not in the :blue_book: dictionary

This includes both expected items (2229) from .github/actions/spelling/expect/alphabet.txt .github/actions/spelling/expect/expect.txt .github/actions/spelling/expect/web.txt and unrecognized words (1)

Dictionary Entries Covers Uniquely
cspell:cpp/src/lang-jargon.txt 11 1 1
cspell:swift/src/swift.txt 53 1 1
cspell:gaming-terms/dict/gaming-terms.txt 59 1 1
cspell:monkeyc/src/monkeyc_keywords.txt 123 1 1
cspell:cryptocurrencies/cryptocurrencies.txt 125 1 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

      with:
        extra_dictionaries:
          cspell:cpp/src/lang-jargon.txt
          cspell:swift/src/swift.txt
          cspell:gaming-terms/dict/gaming-terms.txt
          cspell:monkeyc/src/monkeyc_keywords.txt
          cspell:cryptocurrencies/cryptocurrencies.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

check_extra_dictionaries: ''
Errors (1)

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

:x: Errors Count
:x: ignored-expect-variant 6

See :x: Event descriptions for more information.

:pencil2: Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

:microscope: You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. :wink:

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Nov 22 '24 14:11 github-actions[bot]

Overhauled the PR to adopt my changes over @DHowett's.

a4lg avatar Nov 22 '24 14:11 a4lg

@DHowett @lhecker I'm glad to see that there's a plan to fix #18006 for version 1.21 and 1.22 (on the servicing pipeline)! For the time your team incorporate (backport) the fix in those versions, I made a branch wsl-escape-single-quotes-for-v1.22.

The code is identical to the PR version 2 (that fits 1.21 and 1.22 better than version 4) but incorporates some clarifications from the final merged version (PR version 4).

a4lg avatar Nov 24 '24 05:11 a4lg

Sweet! That saves me a bunch of time as usually I’m doing the backports myself. Thank you :)

DHowett avatar Nov 24 '24 05:11 DHowett

f62754397 (1.21) and 787872875 (1.22, also what a weird-looking SHA1 prefix) queued for servicing.

DHowett avatar Nov 25 '24 21:11 DHowett