Code that will only execute once
Finally a usecase for Vigil!
def main(): raise Exception()
Excerpt from the "language specification":
It goes without saying that any function that throws an exception which isn't caught is wrong and must be punished.
If an oath is broken, the offending function [...] will be duly punished.
Simple: it will be deleted from your source code.
The only way to ensure your program meets its requirements to absolutely forbid code that fails to do so. With Vigil, it will do this for you automatically.
There are other ways to do this, because Vigil provides the keywords
swear which are basically oaths to adhere to certain pre- and post-conditions:
def main(): swear 0 > 1
Pretty much any Linux distro, 9 chars
This one is a classic!
Put this in a file and run it:
> ed a #!/bin/rm . wq foo > ls Mail mbox foo > chmod 777 foo > ./foo > ls Mail mbox
Aaand it's gone!
As to what is going on:
I'm really just running
#! is called a shebang. And if you put one of these followed by a path to some executable as the first line in your script, the program loader will execute your script file with whatever you wrote there - the default is usually
#!/bin/sh (Bourne-again shell / Bourne shell). The first argument passed to this script will be the filename itself (which is why you see so many solutions including
$0 and the likes in here); so by making my file contain
#!/bin/rm and running it, all I'm doing is passing the filename of my file to
x86 binary, 4 bytes
F0 0F C7 C8
Assumption: Must be run on a P5 Pentium CPU.
The above instruction is commonly known as the F00F bug. It attempts to execute an invalid instruction, prefixed with lock.
This freezes the CPU up completely (not a halt nor a reboot) and it doesn't even require root access.