Wanted

Wanted: A bash command that undoes the previous bash command. The name of the command shall be “oops.” It will be written in an object oriented programming language.

See the whole “WANTED” list here.

Comments

  1. #1 Aaron Luchko
    August 6, 2010

    If you were just talking about BASH commands, ie
    $ EXPORT foo=bar
    $ undo

    that might be possible (though I don’t know how useful).

    If you’re talking about
    $ rm-rf*
    $ undo

    than you’re talking about a version controlled file system, and probably RAM too.

    It would be nice but it strikes me as very infeasible.

    Particularly if you want to extend it to.

    $ mail -s “You’re a jerk” boss@mycompany.com
    $ undo

  2. #2 Marion Delgado
    August 6, 2010

    without micro-backup, you can’t do it. (I.e, something like TimeMachine but with way more polling and copying).

    It would be a mark of severe mental illness to think you could handle all the possible implications of every command combination.

    Therefore, the “command” will end up being something like, get timestamp from command-before-last in .history, do a restore from that on any files changed with last command.

    And the micro-backup will do most of the work.

    We all want things, but we don’t all get them.

  3. #3 Marion Delgado
    August 6, 2010

    Also, QED, the requirement for it being an object oriented language is foolish.

    There are well-established folder-walk and backup functions out there, and whether they’re functional, procedural, or object-oriented is pretty much irrelevant, unless you’re willing to swallow the humiliation of having your python script be doing nothing but a bunch of system calls wrapped for no earthly reason in a Potemkin object.

  4. #4 Marion Delgado
    August 6, 2010

    That all said, I think Greg is mainly being whimsical and humorous here. So the above is why I think so.

  5. #5 chris y
    August 6, 2010

    This reminds me of my possible retirement project to develop a new object oriented programming language to be called Mott.

    Mott the OOPL.

  6. #6 Ange
    August 6, 2010

    What about a command that removes previously written comments that demonstrate that the person who wrote them has a delay switch on their sense of humor? It could be called “Doh!”

  7. #7 Tony Sidaway
    August 6, 2010

    You can do this in Scheme using call-with-current-continuation, but that’s about a googolplex of right brackets you’ll never see again. The programmer will need to be sedated for the rest of his life and who knows what unthinkable hideous unborn things might be drawn by the smell of burning entropy. Messing with causality doesn’t come cheap.

    But not object oriented. I never go meddling with things I might possibly understand.

  8. #8 Virgil Samms
    August 6, 2010

    The general case is impossible. Not just very improbable, but formally impossible. Proof:
    >1$ alias oops=’ls’
    >2$ oops

  9. #9 Greg Laden
    August 6, 2010

    I wish I could take back this blog post.

  10. #10 AnonymousCoward
    August 6, 2010

    $ oops
    sh: oops: command not found

  11. #11 Virgil Samms
    August 6, 2010

    It appears someone has already written the program oops:
    Uppsala Software Factory – OOPS Manual

  12. #12 Gray Gaffer
    August 6, 2010

    You could always switch to the Pick OS. Everything is journaled with rewind.

    $ post blog “need bash undo” -v
    $ oops -1
    oops: ERROR: cannot undo reality. Deal with it.

  13. #13 Marion Delgado
    August 6, 2010

    IT’s worse – much worse – than Greg thinks, Ange.

    I believe someone DID write oops …

    all in one take …

    … then immediately tried it out.

  14. #14 gruebait
    August 6, 2010

    I want a toe un-stubber.

  15. #15 Rob
    August 6, 2010

    QED, the requirement for it being an object oriented language is foolish.

    yeah, oops in an object oriented programming language is foolish

  16. #16 Marion Delgado
    August 6, 2010

    Rob and Ange, it actually made me think of Nethack – from, I think, the same place Python came from. Unlike the other roguelike branch, the *hacks tried to think of every possible combination of the person, taking action Y, sometimes with object X, on object or creature Z. An undo might even be possible there.

  17. #17 Marion Delgado
    August 6, 2010

    Looking at the WANTED list, I think AdBlock for a site you’re trying to help is not good. “curtains” seems reasonable. I’d guess a greasemonkey script would be the easiest way? for all pages in the greasemonkey list,

    e.g.
    scienceblogs.com
    scientopia.org
    blogs.discovermag.com

    You run:

    window.scrollBy(0,50); // Zero Right, 50 down

    Or whatever.

  18. #18 James McCann
    August 8, 2010

    The best solution I can think of is to run everything on a virt and take a snapshot of the virt after every shell command, then oops just restores the previous virt state.

    I am pretty sure it would suck.

  19. #19 Greg Laden
    August 8, 2010

    Ok, folks, we can do better. Really.

    A well written bash command will return 0 on completion, a different number on an error, will send output to standard output and take date in from standard input. And so on.

    These things do not happen because the pink unicorn declares it so. These things happen becasue a well written bash command includes these things in the code.

    All “oops” has to do is to invoke the opps parameter of the previously called bash command. The oops stack is where well behaved bash commands store pointers to the necessary data to undo a command. Thus, oops can use the stack to undo multiple previous commands. Not all command can be undone, just as in today’s world not all things that can be undone in word processors or file management gui’s and so on can be undone.

    Certain commans, obviously, make no sense to undo. How would one undo an LS.

    sort foo > bar is easy. oops deletes bar. sort foo >> bar is esy. Oops buffer stores a pointer to the last lin in bar before the command. Ooops, then, would delete the contents of the file following the pointer.

    Ooops can be limited to a maximum amount of record keeping except when certain command switches are in place, which would force the command to use the overhead necessary.