-
-
Notifications
You must be signed in to change notification settings - Fork 866
fix: prevent "no route for conn:..." errors and add shell path expansion #3152
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
Open
re2zero
wants to merge
1
commit into
wavetermdev:main
Choose a base branch
from
re2zero:pr/merge-tideterm-fixes-clean
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Copyright 2026, Command Line Inc. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package shellexec | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestPosixCwdExprNoWshRemote(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| cwd string | ||
| sshUser string | ||
| want string | ||
| }{ | ||
| { | ||
| name: "tilde-dir-uses-username-home", | ||
| cwd: "~/.ssh", | ||
| sshUser: "root", | ||
| want: "~root/.ssh", | ||
| }, | ||
| { | ||
| name: "tilde-root-uses-username-home", | ||
| cwd: "~", | ||
| sshUser: "root", | ||
| want: "~root", | ||
| }, | ||
| { | ||
| name: "tilde-slash-uses-username-home", | ||
| cwd: "~/", | ||
| sshUser: "root", | ||
| want: "~root/", | ||
| }, | ||
| { | ||
| name: "non-tilde-falls-back", | ||
| cwd: "/var/log", | ||
| sshUser: "root", | ||
| want: "/var/log", | ||
| }, | ||
| { | ||
| name: "missing-user-falls-back-to-home-var", | ||
| cwd: "~/.ssh", | ||
| sshUser: "", | ||
| want: "\"$HOME/.ssh\"", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got := posixCwdExprNoWshRemote(tt.cwd, tt.sshUser) | ||
| if got != tt.want { | ||
| t.Fatalf("posixCwdExprNoWshRemote(%q, %q)=%q, want %q", tt.cwd, tt.sshUser, got, tt.want) | ||
| } | ||
| }) | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
For fish shell and PowerShell, what is the recommended way to represent ~/path with spaces as a single safe argument while preserving home expansion?💡 Result:
For fish shell, the recommended way is to use double quotes around the path: "
/path with spaces". This preserves tilde () expansion to the home directory while treating the entire path, including spaces, as a single argument. Tilde expansion occurs for unquoted ~ at the start of a word or inside double quotes when followed by /. Examples: ls "/My Documents" cd "/My Documents" Single quotes '~/path' prevent tilde expansion, passing ~ literally. For PowerShell, ~ expansion is not automatic for paths (especially external commands), so use the $HOME variable inside double quotes: "$HOME/path with spaces". This expands to the full home path and handles spaces as a single argument. To expand ~ explicitly if needed: Resolve-Path ~/path then quote, but using $HOME is simpler and more reliable. Examples: ls "$HOME/My Documents" & "$HOME/My Documents/myapp.exe"Citations:
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 966
🏁 Script executed:
rg -n "fishCwdExpr|pwshCwdExpr" pkg/shellexec/shellexec.go -A 3 -B 1Repository: wavetermdev/waveterm
Length of output: 300
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 46
🏁 Script executed:
rg "fishCwdExpr|pwshCwdExpr" --type goRepository: wavetermdev/waveterm
Length of output: 193
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 1153
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 762
🏁 Script executed:
rg -n "fishCwdExpr\(|pwshCwdExpr\(" pkg/shellexec/shellexec.goRepository: wavetermdev/waveterm
Length of output: 147
🏁 Script executed:
rg "fishCwdExpr\(|pwshCwdExpr\(" --type go -nRepository: wavetermdev/waveterm
Length of output: 201
🏁 Script executed:
rg "fishCwdExpr\(|pwshCwdExpr\(" --type goRepository: wavetermdev/waveterm
Length of output: 193
🏁 Script executed:
rg "fishCwdExpr|pwshCwdExpr" --type go -lRepository: wavetermdev/waveterm
Length of output: 90
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 153
🏁 Script executed:
rg "fishCwdExpr|pwshCwdExpr" -t go --no-filenameRepository: wavetermdev/waveterm
Length of output: 139
🏁 Script executed:
cat -n pkg/shellexec/shellexec.go | tail -100Repository: wavetermdev/waveterm
Length of output: 4267
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 94
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 197
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 644
~/...paths in fish and pwsh need proper quoting to handle spaces safely.The code returns tilde-prefixed paths raw without escaping (lines 176-177 for
fishCwdExprand 188-189 forpwshCwdExpr). For paths with spaces, this creates unsafe behavior:~/path with spacesgets split on whitespace. Use double quotes:"~/path with spaces"to preserve tilde expansion while handling spaces safely.~) is not automatically expanded in path contexts. Use$HOMEinstead:"$HOME/path with spaces"for reliable expansion and safe handling of special characters.Same issue applies to lines 192-193 (special char quoting is skipped for tilde paths).
🤖 Prompt for AI Agents