Live data from Hacker News

Moreutils – Unix tools that nobody thought to write (2012)

joeyh.name

1–10 of 225 posts

Re: Moreutils – Unix tools that nobody thought to write (2012)

#4
post #3

> sponge Why not use > file? > mispipe In bash there's PIPESTATUS for that.

Re sponge: the shell will open the output file for writing before invoking the command so in the example joey provides, /etc/passwd will be an empty file by the time sed opens it.

Re: Moreutils – Unix tools that nobody thought to write (2012)

#6
post #5
post #3

> sponge Why not use > file? > mispipe In bash there's PIPESTATUS for that.

> Why not use > file? I'm assuming sponge buffers everything in memory so you don't get concurrent modification bugs.

Yes, if you try to sed a file back to itself for instance you'll get a truncated file (or maybe a no-op?). In fact, that's exactly the example sponge's manpage uses.

Re: Moreutils – Unix tools that nobody thought to write (2012)

#8
post #3

> sponge Why not use > file? > mispipe In bash there's PIPESTATUS for that.

Re sponge: the shell will open the output file for writing before invoking the command so in the example joey provides, /etc/passwd will be an empty file by the time sed opens it.

heh, yeah that's a mistake everyone makes once, and hopefully not more than once.
Post reply on HN