This looks great, but is the approach of “try this command over and over” dangerous for pipelines that may contain “non-idempotent” operations?
Specifically, and for example, I use the “perl -pi.bak -e …stuff… filename.glob “ pattern often, to search-and-replace text in files, and while figuring out the regex to use in there, I think this would try over and over, … and if my filename.glob was too broad (i use “*” too often), my directory would quickly fill up with files like filename.bak.bak.bak.bak.bak.
I realize I’ll probably get a “don’t do that, then” comments… but isn’t there a case where you’d want to have a “don’t ‘hit return’, until the user signals that it’s ok to make an attempt to execute? Does this already exist in there and I missed it?
Who am I to tell anyone “don’t do”! :)
Actually, my initial idea was in fact to have such a “run/pause” feature. But then I thought I could maybe take a risk and go without it? It could even work! :) So it’s certainly not alien to me; however, I’m also not very sure now: would it then bring enough value over just writing the stuff on a normal shell prompt? What do you think? I’m genuinely curious; I’m deep enough in the trenches now, that I’ve already lost some end-user perspective, so your input would be very valuable to me here and now. Also, and maybe especially: would you think the -i.bak option would make any sense with the pause/run feature? Given that you would probably want to pause-run more than once anyway, so you might still get some .bak.bak.baks?… or do I not see something?… This is certainly interesting…
original commenter here: I was thinking about this some more, and I bet you can get tricky using capabilities(7) or other containment mechanisms (on Linux, at least) to render the filesystem upon which you’re noodling to be immutable.
Oh, wow; now that would be seriously amazing hack if it works… Thank you good sir for the idea, it totally made my eyes wide open… I wonder if it’s really possible, and how much work it would require…
A more complex project to write, but perhaps a FUSE driver that act as writable snapshot overlay which doesn’t commit to disk. write / unlink “works” but only affects virtual filesystem nodes.
Yeah, you’d need to be especially careful with find -exec or xargs when the operation might involve copying/modifying/deleting files.