landley / toybox

toybox
http://landley.net/toybox
BSD Zero Clause License
2.42k stars 337 forks source link

diff from stdin #427

Open dlegaultbbry opened 1 year ago

dlegaultbbry commented 1 year ago

If you diff from stdin in a read-only location, the creation of the temporary file to fill in the contents of stdin fails. Wouldn't it be preferable to check if the CWD is writable and if not attempt to use some other locations such as TMP, TEMP, /tmp, /dev/shm, etc. to try and create the temporary file contents?

landley commented 1 year ago

Sorry for the delay, I was doinig a complete rewrite of diff last year which got parked, and I'm going "I should probably try to finish that and promote it this weekend".

Diff is in pending, so I treat it with slightly less urgency, but if somebody's waiting for it I need to bump it up, but I'm trying to finish rewriting/promoting fold.c before opening the next can of worms, and went down a utf8 rabbit hole on that which resulted in redoing demo_utf8towc.c...

It's not quite https://xkcd.com/349/ but there's some can-of-worms nesting going on. Not unusal around here, to be honest...

dlegaultbbry commented 1 year ago

No issue with the delay. I was just reporting the issue which is probably going to be rare in practice on desktops and is more likely to happen in locked down embedded systems. I patched it to check if current location is writable else fall back on /dev/shmem which is always available on QNX. That may not be the case on other operating systems.

I fully understand that refactoring can be thought as a simple exercise until you get into the weeds. Reminds me of renovating a house and you haven't opened the walls yet to see what lurks.

You own the schedule on what is promoted, I'm not asking/expecting any favorable treatment from this reporting.

Thanks!