On Fri, Jun 20, 2025 at 08:32:16AM +0200, Bernhard Voelker wrote: > On 6/19/25 18:55, Marc Chantreux wrote: > > so out of curriosity: is there another possible usage ? > > Maybe the 'sed -i ... FILE' case?
sorry for my poor english. what I was saying is "I don't know any other way of using sponge than make sure every rhs of the pipe is closed before releasing data to the remain components. sed -i obvioulsy doesn't work with pipes. > Support in a general way could look like: > > sponge-tool FILE cmd args... > > where 'sponge-tool' passes the content of FILE to stdin of 'cmd', > and writes the stdout back to FILE. well. * sponge is more generic * as long as you have sponge, you can write stuff like that inline() { local SELF="$1"; shift "$@" "$SELF" | sponge "$SELF" } I did it long time ago before I realized I didn't use it because it's so easy to write set A B C D for it; do grep foo $it | sponge $it; done even shorter with shells with non-algol control statements (zsh, rc, es, …) set A B C D for it { grep foo $it | sponge $it } for it (A B C D) { grep foo $it | sponge $it } Regards -- Marc Chantreux Pôle CESAR (Calcul et services avancés à la recherche) Université de Strasbourg 14 rue René Descartes, BP 80010, 67084 STRASBOURG CEDEX 03.68.85.60.79