B
B
Boris the Animal2021-06-17 12:07:55
PowerShell
Boris the Animal, 2021-06-17 12:07:55

Why doesn't calling C:\Program Files\Git\bin\sh.exe via PowerShell with a command pass to it work?

I execute the command:

& 'C:\Program Files\Git\bin\sh.exe' 'cd /e/Git/Project && git pull' | Out-String


I get the output:
sh.exe : /usr/bin/bash: cd /e/Git/Project: No such file or directory
At line:1 char:1
+ & 'C:\Program Files\Git\bin\sh.exe' 'cd /e/Git/Project ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (/usr/bin/bash: ...le or directory:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError


In this case, if you open the command line and call:
"C:\Program Files\Git\bin\sh.exe" -c "cd /e/Git/Project && git pull"

then everything works great.

How to call all this correctly through PowerShell?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxKozlov, 2021-06-17
@MaxKozlov

Why not just run
"C:\Program Files\Git\bin\git.exe" ? why else a layer of sh ?

cd e:/Git/Project
& "C:\Program Files\Git\bin\git.exe" pull

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question