-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix(git): expand user home dir first #437
fix(git): expand user home dir first #437
Conversation
subcommands/git/cmd.go
Outdated
@@ -74,6 +72,11 @@ func doGitCreds(cmd *cobra.Command, args []string) { | |||
var gitHelperCommandArgs []string | |||
|
|||
helperName := "fio" | |||
if strings.HasPrefix(helperPath, "~/") { |
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.
this is tricky:
golang/go#4140
I think this would also happen in the docker helper. After reading those bug comments like "what about Win32", I'm more inclined to check string.contains("~")
and just return an error like golang chose:
golang/go@8b6534b#diff-7c289d314f17f4e276724c62cfd8dd5e2c7dffad2d900987f8eae83192ad15bdL131
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.
I agree to this.
It also raises a ton of questions like what about fioctl configure-git --creds-path='~/.config'
?
(In the above case there must be no expansion, but single quotes are not passed to the program by shell).
...Or what about non-Bash shells?... which have no tilda expansion (and should not have by design).
I'd say: let the shell do its job, and let's not pretend to "fix" it... as there are so many use cases we're burrowing a rabbit hole.
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.
This makes sense to me. I adjusted it to also just throw an error for both git
and docker
. The only difference I did, was to always throw an error regardless of OS. I actually think this will be beneficial to the end user since it conveys more information.
When using it like `fioctl configure-git --creds-path ~/.config` there is no problem however if you use it like `fioctl configure-git --creds-path=~/.config` there is. The reason lies in the fact that in the first example the shell already expands the ~ into the absolute path of the homedir, in the second it will not. Let's throw an error the same way golang does itself. golang/go@8b6534b#diff-7c289d314f17f4e276724c62cfd8dd5e2c7dffad2d900987f8eae83192ad15bdL131 Signed-off-by: Eric Bode <[email protected]>
dc8beed
to
037dfae
Compare
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.
seems okay. i'll defer to @vkhoroz
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.
LGTM
When using it like
fioctl configure-git --creds-path ~/.config
there is no problem however if you use it likefioctl configure-git --creds-path=~/.config
there is.The reason lies in the fact that in the first example the shell already expands the ~ into the absolute path of the homedir, in the second it will not.