News for hackers. Stuff that matters.
Re:Why SQLite Does Not Use Git by IshKebab on Sunday July 23, 2023 @09:21AM (#36835057)
The Unix philosophy was a very rough guideline from the 70s, not a divine commandment that must be followed unwaveringly.

There are a gazillion examples of excellent pieces of software that don't do "one thing" that can be piped as unstructured text into another program.

Imagine editing a spreadsheet like `cat foo.xls | select-cell B3 | replace '=B2+1' > foo.xls`.

Laughable. But how many people decry Excel for "not more than one thing"? You probably haven't even considered it.

I'd put it up there with "premature optimisation" as one of the most damaging programming mantras.

Re:Why SQLite Does Not Use Git by tzs on Sunday July 23, 2023 @10:32AM (#36835663)
> Imagine editing a spreadsheet like `cat foo.xls | select-cell B3 | replace '=B2+1' > foo.xls`.

It would be even more cumbersome than that. After that command you'd have to restore foo.xls from a backup, and then do the edit again this time remembering that the "> foo.xls" executes before the pipe executes. :-)

I wonder if anyone has written something to make pipes like that work? E.g., write two programs, "replace" and "with" that could be used like this:

  replace foo.xls | ... | with foo.xls
What "replace [file]" would do is set a write lock on the file, copy the file to stdout, then release the lock.

What "with [file]" would do is copy stdin to the file, after obtaining a write lock on the file. I think most shells would start the components of a pipe in order so "replace" should be able to set its lock before "with" tries to get a lock, but to be safe "with" could be written to buffer incoming data and only start checking the lock after it has received a significant amount or seen an EOF on stdin. Or "replace" and "with" could coordinate using some out-of-band method.

Re:Why SQLite Does Not Use Git by Sprocklem on Thursday July 27, 2023 @02:22PM (#36898017)
`sponge` from moreutils more or less does this.