You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey all.
One of my command flags is a string that represents a path, set either in an environment variable or passed using that flag. When in a Linux environment, printing the command usage will show this environment variable in the correct path format:
I've tried things like strings.Replace(path, string(filepath.Separator), "/", -1) or even regex to replace the backslash but the backslashes always get printed twice (I'm guessing they are getting escaped). Tried cmd.exe, Powershell, git-bash and the behaviour is the same.
The text was updated successfully, but these errors were encountered:
The code is specifically branching based on the flag.Value.Type() which in this case is string since you called StringP. If you want it to use the other path (which will use %s and not %q then you could force that by making your own flag type that describes its type as something different.
I had another issue refer to this same issue and I made a PR here: spf13/pflag#347 I don't think that it is going to be picked up as-is (see comment/thread linked below).
Refer to the issue in the pflag repo; but there is an in-depth reply here: spf13/pflag#346 (comment) that you can read/comment on as well.
Closing in preference of continuing the conversation in that thread instead.
Hey all.
One of my command flags is a string that represents a path, set either in an environment variable or passed using that flag. When in a Linux environment, printing the command usage will show this environment variable in the correct path format:
Specifies pack root folder. Defaults to CMSIS_PACK_ROOT environment variable (default "/tmp/pack-root")
However, declaring this environment variable in Windows and printing the generic usage for this command will show the path in escaped backslashes:
The code responsible:
I've tried things like
strings.Replace(path, string(filepath.Separator), "/", -1)
or even regex to replace the backslash but the backslashes always get printed twice (I'm guessing they are getting escaped). Tried cmd.exe, Powershell, git-bash and the behaviour is the same.The text was updated successfully, but these errors were encountered: