cmhughes / latexindent.pl

Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break removal. It can also perform string-based and regex-based substitutions/replacements. The script is customisable through its YAML interface.
GNU General Public License v3.0
884 stars 84 forks source link

Allow `latexindent file.tex > file.tex` #269

Closed thomasahle closed 3 years ago

thomasahle commented 3 years ago

Yesterday I wanted to indent some latex code, and I ran latexindent file.tex, which of course outputs the result to the terminal. Admittedly I didn't read the docs, but I then ran latexindent file.tex > file.tex, which I expected would replace file.tex with the indented version. Instead, it deleted my last hour of work.

actual/given output

My file file.tex ended up empty.

desired or expected output

I would expect the command to be similar to latexindent -w file.tex.

anything else

I know this isn't strictly necessary since the -w command exists, but it seems like it wouldn't hurt to allow the pipe version as well. If only as a way to help stupid people not lose their work.

cmhughes commented 3 years ago

Hello, Thanks for this.

I'm not sure that this is a problem with latexindent.pl. See, for example, the details within the following links:

If I've misunderstood this, please do let me know. Best Chris

thomasahle commented 3 years ago

I see. I expected this had to do with the buffering used by latexindent, but if the right hand side of > is evaluated before the left, I guess there is no way to work around it.

cmhughes commented 3 years ago

Yes, that's my understanding.

I don't think this is particular to latexindent.

But, if I'm wrong then please do let me know :)

cmhughes commented 3 years ago

I'm going to close this, but do let me know if you have any follow-up on this.