1. 14

    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?

    1. 3

      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…

      1. 3

        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.

        1. 2

          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…

          1. 2

            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.

      2. 2

        Yeah, you’d need to be especially careful with find -exec or xargs when the operation might involve copying/modifying/deleting files.