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.
If you were just talking about BASH commands, ie
$ EXPORT foo=bar
that might be possible (though I don’t know how useful).
If you’re talking about
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” firstname.lastname@example.org
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.
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.
That all said, I think Greg is mainly being whimsical and humorous here. So the above is why I think so.
This reminds me of my possible retirement project to develop a new object oriented programming language to be called Mott.
Mott the OOPL.
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!”
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.
The general case is impossible. Not just very improbable, but formally impossible. Proof:>1$ alias oops=’ls’>2$ oops
I wish I could take back this blog post.
sh: oops: command not found
It appears someone has already written the program oops:Uppsala Software Factory – OOPS Manual
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.
IT’s worse – much worse – than Greg thinks, Ange.
I believe someone DID write oops …
all in one take …
… then immediately tried it out.
I want a toe un-stubber.
QED, the requirement for it being an object oriented language is foolish.
yeah, oops in an object oriented programming language is foolish
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.
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,
window.scrollBy(0,50); // Zero Right, 50 down
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.
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.
Current ye@r *
Leave this field empty
Notify me of follow-up comments by email.
Notify me of new posts by email.
Notify me of followup comments via E-Mail.
A novel by Greg Laden ...
Read my posts on climate change and related topics.
Enter your email address to subscribe to this blog and receive endless notifications of new posts by email.