Fish integration: Use -- in string to signify beginning of positional…#189994
Merged
meganrogge merged 1 commit intomicrosoft:mainfrom Aug 9, 2023
Merged
Fish integration: Use -- in string to signify beginning of positional…#189994meganrogge merged 1 commit intomicrosoft:mainfrom
meganrogge merged 1 commit intomicrosoft:mainfrom
Conversation
… arguments
In some cases in VSCode + fish you can run a command like:
```
echo 'hi
-- hi'
```
It's perfectly legitimate and will run in a normal terminal just fine.
However VSCode's shell extensions will raise an error:
```
string join: -- hi': unknown option
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/fish_xdg_data/fish/vendor_conf.d/shellIntegration.fish (line 1):
string join ";" $argv
^
in command substitution
called on line 65 of file /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/fish_xdg_data/fish/vendor_conf.d/shellIntegration.fish
in function '__vsc_esc' with arguments 'E echo\ \'hi "" --\ hi\''
called on line 72 of file /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/fish_xdg_data/fish/vendor_conf.d/shellIntegration.fish
in function '__vsc_cmd_executed' with arguments 'echo\ \'hi\n\n--\ hi\''
in event handler: handler for generic event 'fish_preexec'
(Type 'help string' for related documentation)
```
The problem is `string` interprets the `--hi` as a switch. By adding `--` we can negate that behavior and let `--hi` be treated as a positional argument.
See the [string documentation][s]
> Arguments beginning with - are normally interpreted as switches; -- causes the following arguments not to be treated as switches even if they begin with -. Switches and required arguments are recognized only on the command line.
[s]: https://fishshell.com/docs/current/cmds/string.html
150c471 to
e9018d5
Compare
Tyriar
approved these changes
Aug 9, 2023
Member
Tyriar
left a comment
There was a problem hiding this comment.
Looks good to me provided it doesn't cause an error for single/multi-line commands. @meganrogge could you test in fish on your mac to make sure it works?
Collaborator
meganrogge
approved these changes
Aug 9, 2023
Collaborator
meganrogge
left a comment
There was a problem hiding this comment.
Thanks for working on this!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

… arguments
In some cases in VSCode + fish you can run a command like:
It's perfectly legitimate and will run in a normal terminal just fine.
However VSCode's shell extensions will raise an error:
The problem is
stringinterprets the--hias a switch. By adding--we can negate that behavior and let--hibe treated as a positional argument.See the string documentation
See: #187248
This is my first pull request to this repository, and I am happy to amend, update, as needed. To the best of my knowledge I've satisfied the guidelines.