Reputation: 11317
I'm trying to write a kind of redirect script to stabilize the clang-format executable used by Visual studio over the different projects that I have.
For example:
So instead of using the default clang-format I'm trying to use a clang-format.cmd that based on the project has been using.
My current approach:
@echo OFF
:checkFormat
IF EXIST "clang-format.exe" (
call clang-format.exe %* <&0 >&1
) ELSE (
REM Loop the dir tree until the root the of the disk
if "%cd:~3,1%"=="" (
exit -1
)
cd ..
goto checkFormat
)
However, whenever this script gets called from Visual Studio, I get an error:
An error occurred while formatting with ClangFormat The pipe has been ended.
I've tried replacing the call with another cmd that prints something to file and it doesn't seem to be to called. However, I did already add similar file creation before the 'call', which confirms it is being reached and in the directory that I expect.
How do I verify what the content is of STDIN? How do I redirect this stdin to the actual executable?
EDIT When running from within a CMD-prompt, it gives following error:
The handle could not be duplicated during redirection of handle 0.
Upvotes: 1
Views: 432
Reputation: 82390
Remove the part <&0 >&1
, because the constructs are wrong.
>&1
will be interpreted as
append handle 1 (STDOUT) to handle 1 (STDOUT)
That can't work.
The <0&
will be interpreted nearly the same way
append handle 0 (STDIN) to handle 0 (STDIN)
Upvotes: 1