0

How would one directly change the file being formatted by Uncrustify in Windows? All the docs suggest is to pipe the standard output to another file. Is there a clean batch script or a way in Uncrustify to just change the file directly?

I tried doing a script like the following:

for /R %%f in (..\..\..\src\Funs\*.c) do (
..\..\Uncrustify\uncrustify -c ..\..\Uncrustify\g.cfg -f %%f > %%f
)

The problem is that the file ends up empty, which makes sense. I just don't know a workaround

Stefan G.
  • 167
  • 7
  • When the command interpreter recognises an output redirection `>`, it opens (creates) the related file for being written with the file pointer (re-)set to zero, so it becomes an empty file; I don't see a good work-around for this... – aschipfl Jun 30 '16 at 22:08

1 Answers1

0

--replace is your friend (without -f):

for /R %%f in (..\..\..\src\Funs\*.c) do (
..\..\Uncrustify\uncrustify -c ..\..\Uncrustify\g.cfg --replace %%f
)
teki
  • 2,032
  • 1
  • 12
  • 6