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:
- Project 1: Has .clang-format based on LLVM 5.0.0
- Project 2: Has .clang-format based on LLVM 8.0.0
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.