On Thu, Jun 26, 2025 at 03:06:56PM -0500, Rob Landley wrote: > On 6/21/25 08:56, Marc Chantreux wrote: > > On Fri, Jun 20, 2025 at 09:21:28AM -0400, Michael Stone wrote: > > > I agree with this, and question why the austin group is considering it at > > > all. > > > > well. I shell almost every day for about 30 years now and I'm really > > happy about this because sponge is so convenient. > > Can't you just do: > > sponge() { local X=$(base64); base64<<<"$X" > $1; } > > To be honest, every time I've needed something like this... isn't that what > mktemp is for? > > thingy <"$IN" > ${BLAH:=$(mktemp .blahxxxxx)} && mv -f $BLAH "$IN" || > { rm -rf $BLAH; return 1; }
the second one is almost the way I replace sponge whenever * I share/publish a script (to remove the moreutils dependency) * I need to be sure the pipe worked I just try to write in /dev/shm (without really knowing if there are some performance gain). > I asked for opinions about this on the toybox list and the Android base OS > maintainer wasn't impressed either: > > http://lists.landley.net/pipermail/toybox-landley.net/2025-June/030741.html Nowadays I'm interested to use busybox as my rootfs so I replaced my zsh habits by dash ones. so to compare zsh habit # becames -----------------------------#---------------------------------- path=${(uM)path:#*/local/*} # PATH=$( echo $PATH | # tr : '\n' | # awk '! (/local/ || seen[$0]++ )' # paste -sd: ) # <<< # l() printf "%s\n" "$@" # getnew | paste - <( getold ) # rm -rf old; mkfifo old # getold > old & getnew | paste - old # rm old # # **(.u:root:)~*.png # find . -type f -user root \ # -not -name '*.png' -print0 | # xargs -0 and so on ... So I don't *need* zsh but I wouldn't miss it when it comes to interactive sessions or throwable scripts not only because it's easier to write and read but also because I don't want to reinvent the wheel the way everyone does in its own corder for decades. Not only it's shorter, battle tested, documented and easier to use so if it's standard it becomes a custom. Self taught shell scripters (I guess from my personnal experience that most of them are) don't even know about mkfifo, tee, xargs so they are screwed when <() is not enough … then an idiot shows off and say "real programmers use python" and here we are, 25 years later, maintaining ridiculous long scripts that adds python as dependency just because shellscripting is way underated. I discovered sponge because there was a package moreutils and I was searching for a perl moreutils module so it was an accident due to the fact that the author was also a perl monger. pee (from moreutils), stest (from suckless-tools), mk (from 9base, originated from Unix System 10, the ultimate unix) are also part of the tools I would like to see as default. > Beyond the "this really doesn't come up much" problem I have to admit it. but if you give a look at tools available in POSIX, I don't know how is criteria relevant. > friends can know if there was an error in processing and keep the old file. > Sponge in a pipe doesn't know if the command piping into it failed, so > unless you define "no input" as keeping the old file intact (which still > doesn't catch a lot of error cases) it will replace the output file whether > you want it to or not, it just delays doing it slightly so you can use the > same input and output. This is a limitation and you have to assume it when you use it. every tool has its limitation and to me it's one of the vertue of unix. Anyway: thank you so much for sharing this feedback. I truely understand your point and writing this post made me realized that I'm using bob -u in Makefiles much more than sponge nowadays. 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