I have the path of git --exec-path | sed 's#/#\\#g'
, I want to use explorer
to open this path, like explorer "path"
, pseudocode: git --exec-path | sed 's#/#\\#g' | explorer "path"
, how to implement the last pipe?
Asked
Active
Viewed 222 times
0

Wenfang Du
- 8,804
- 9
- 59
- 90
-
2May be `explorer "$(git --exec-path | sed 's#/#\\#g')"`. – tshiono Dec 01 '21 at 02:48
-
@tshiono Thanks, that will open the folder successfully, but I tried to echo it, `echo explorer "$(git --exec-path | sed 's#/#\\#g')"`, the output has no double quotes though: `explorer C:\Program Files\Git\mingw64\libexec\git-core`. – Wenfang Du Dec 01 '21 at 03:05
-
2@WenfangDu That's good; the quotes *shouldn't* print when you put `echo` in front of the command, because they're parsed, applied, *and removed* before they're passed to the command (whether the command is `echo` or `explorer`). Try `echo explorer "C:\Program Files\Git\mingw64\libexec\git-core"`, and you'll see that the quotes don't print there either. – Gordon Davisson Dec 01 '21 at 03:12
-
1Checkout this great thread: [Windows PATH to posix path conversion in bash](https://stackoverflow.com/questions/13701218/windows-path-to-posix-path-conversion-in-bash), and also `wslpath` program. [Github repo](https://github.com/laurent22/wslpath). – dan Dec 01 '21 at 03:32
-
I don't know about the intrinsincs of _explorer_, but I don't think that this program will be happy to see the quotes. You can easily test this by doing a `cd "c:/Program Files"; explorer '"Git"'`, which would pass `"Git"` to _explorer_, including quotes. Alternatively, try `explorer 'Git'`, which would pass `Git` without quotes. – user1934428 Dec 01 '21 at 08:26