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

tilde_expand in client fails to resolve path #2309

Open
3 tasks done
tgauth opened this issue Dec 2, 2024 · 3 comments · May be fixed by PowerShell/openssh-portable#768
Open
3 tasks done

tilde_expand in client fails to resolve path #2309

tgauth opened this issue Dec 2, 2024 · 3 comments · May be fixed by PowerShell/openssh-portable#768

Comments

@tgauth
Copy link
Collaborator

tgauth commented Dec 2, 2024

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

When passing, ~ as part of a path, i.e. -i ~\.ssh\example_key, the path should resolve to the user's home directory.

Expected behavior

For `user` it would resolve to - `C:\users\user\.ssh\example_user`

Actual behavior

For `user` the following error occurs - `tilde_expand: No such user \\.ssh\\example_key`

Error details

No response

Environment data

Version 8.9 and above

Version

9.8.1.0

Visuals

No response

@tgauth
Copy link
Collaborator Author

tgauth commented Dec 3, 2024

temporary workaround: pass path in with forward slashes, i.e. -i ~/.ssh/example_key

@mgkuhn
Copy link

mgkuhn commented Dec 4, 2024

Isn't the Windows equivalent of ~/ provided by %USERPROFILE%\?

If Windows users want tilde expansion, shouldn't this better be added to either a Windows shell, such as PowerShell or CMD.EXE, or perhaps to the command-line parser that comes with Microsoft's C runtime, which on Windows does some of the jobs (quote processing, word splitting) that on POSIX systems the shell does. This way, one will not have to add such a function to each individual command-line application, like ssh and many others, but can do it once for all Windows command-line applications.

@mgkuhn
Copy link

mgkuhn commented Dec 4, 2024

Longer-term suggestion to Windows Command Line project management, to solve the underlying problem of POSIX and Windows command-line processing currently being very different:

  • ship a POSIX shell with Windows (which does all the usual argument expansions, including tilde expansion); this could start out as a Windows port of something like pdksh, dash or zsh.
  • give that POSIX shell some new interface to application programs that use the Microsoft C run-time, to bypass the traditional CommandLineToArgv command-line parser there and deliver an already word-split argv[] array directly from such a shell to the application's main() function

The problem: Windows currently hands over a command-line as a single string, which the application then retrieves via GetCommandLine and splits via CommandLineToArgv. This seriously complicates command-line processing, as the task is currently split in a rather strange and highly complex way between the shell and the application's C run-time. Instead, just do it like Unix and standardize a way for a shell to hand over an Argv array of strings to an application, and lots of tricky quoting problems and corner cases will vanish.

@tgauth tgauth added 3 - In Review Implementation complete and removed 2 - In progress Implementation is underway labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants