Correctly parsing the -e command line argument
#2633
|
ghostty currently cannot correctly parse (or say in the same way as other terminals) the command line argument Reproduction StepsSituation 1Pass a parameter with spaces to ghostty -e nvim "path with spaces"Expected Behaviornvim opens a file at Actual BehaviorOpen the three files Situation 2Pass a parameter with parentheses to ghostty -e nvim "path with ()"Expected Behaviornvim opens the file Actual Behavior |
Replies: 5 comments 24 replies
|
Fully supportive of figuring out some answer to this. I've converted to a planning discussion until we have an actionable result that we want to take. I also want to note there is some discussion already in a previous PR at #2620. I'll use this comment to provide additional background: I've maintained multiple widely used projects in the past that do shell parsing, and it becomes a very hairy nightmare really quickly. My goal with Ghostty's Second point of background: Ghostty originally didn't support args at all. You can probably use git blame to find the issue that brought this but originally we only allowed single executables to completely bypass this problem. This was unliked for somewhat obvious reasons, but it had very clear semantics at least. My attempt to just use I'm mostly curious how other terminals do it. Note we can't copy the source of a GPL licensed project so we have to be careful, but if anyone can conceptually explain how they work we can mimic that behavior if we find it maintainable. |
|
Hi there, this works this errors Error in second terminal window Not sure if its OK to add to this post of if the root cause belongs to a different issue/PR/discussion |
|
I found a bit of a hacky solution for me (not being an expert) So the main takeaway here is that i start a new fish shell via ghostty to run my bash script successfully Maybe not helpful for you but in case yes i wanted to write it down Thanks |
|
I would strongly welcome it if ghostty also did not launch everything through /bin/sh (or cmd.exe) but just implemented parsing of the given command properly. @mitchellh Maybe we could use something like wordexp for POSIX and CommandLineToArgvW on windows? |
|
Coming back to this, I'd really like to solve this. One suggestion above was to use The original issue as stated was that the Going further into implementation details, I think that running a command through ProposalWhat I'd like to propose is some syntax for This syntax isn't obvious and you'd definitely have to read documentation to understand what's going on, but my expectation is that most users won't ever have to because both usage (in config file or For the config file ones, we will NOT do any shell expansion. We accept the args space-separated as-is. That means the following would NOT work: An alternative would be introducing a new config like |

Promoted to issue #7032