SZEDER Gábor <szeder.dev@xxxxxxxxx> writes: > I was aware that things like 'cmd file >file' don't work, because the > shell opens and truncates 'file' before executing the command, so 'cmd' > will open the already empty file, but I didn't know that 'echo "$(cmd > file)" >file' works. Thanks for letting me know. > > However, this is subject to the portability issues of the shell's > 'echo', i.e. try > > echo "$(cat git.c)" >git.c > > with Bash and Dash. Bash produces the exact same contents, but Dash > turns all '\n' in help and error strings to real newline characters. Besides, that is a bad practice in general if you do not have a guarantee that 'git.c' (or whatever file in question) is small enough not to bust any platform's argv[] length limit. > ... Still, I think it'd be better > to stick to using a good old temporary file: Yes.