_8F+++P]f1Fw
Save this program under the name !
and execute it.
lstack gstack
_ [0,0,0]• create bee
8 [0,0,8]• lstack 1st=8
F [8,8,8]• all lstack=lstack 1st
+++ [8,8,16]• 1st=1st+2nd
[8,8,24]• 3 times
[8,8,32]•
P [8,8,33]• increment 1st
] [8,8,2377900603251621888]• rotate bits of 1st by 2nd steps
f [2377900603251621888]• push lstack 1st ont gstack
1 [8,8,1]• lstack 1st=1
F [1,1,1]• all lstack=lstack 1st
w write gstack to file. lstack 1st=bytes used for file name, lstack 2nd= used file content bytes.
If we look at the stack contents in hex, it gets clearer what’s happening:
lstack[8,8,33]•
is
lstack[0x0000000000000008,0x000000000000008,0x0000000000000021]•
in hex.
If we rotate the bits of the 1st lstack value by 8 to the right, we get
lstack[8,8,2377900603251621888]•
, which is
lstack[0x0000000000000008,0x000000000000008,0x2100000000000000]•
in hex.
Instruction f
pushes the 1st lstack value on the gstack:
gstack[0x2100000000000000]•
Now comes instruction w:
First, the 4-byte words of the gstack get reinterpreted as a stack of UInt8 values:
[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21]•
, in little endian order. The MSB is on top of the stack.
Instruction w
takes the 1st lstack value as number of bytes taken for the file name, and the 2nd lstack value gives the number of bytes stored in the file. lstack[1,1,1]•
means that 1 byte is taken as file name. 0x21
is the ASCII code for !
, which is the name of the program itself. The next single byte (lstack 2nd), the value 0x00
is stored as file content, which is not executable as beeswax program.
4
echo "This program prints gullible if it is executed again."
– totallyhuman – 2017-05-10T21:53:21.7705
possible duplicate of A program that deletes itself
– Peter Taylor – 2014-05-28T07:04:47.4777@PeterTaylor a possible Solution would be the a self delete but as the result are showing it isn't the only one. – Lukei – 2014-05-28T07:21:19.987
1Is it ok, if the programm shuts the PC down? – Knerd – 2014-05-28T08:54:29.063
No restarting the computer is equivalent to halt. – ojblass – 2014-05-28T13:10:49.400
2I feel that this would be much more interesting as a
popularity-contest
type question. Perhaps ask it again, or a similar one. Too many simple low character count winners that are already answered in the program that deletes itself question. – agweber – 2014-05-28T14:16:18.080this is now a popularity contest. – ojblass – 2014-05-28T14:18:16.990
102To a lot of people calling
vi
in a single terminal environment has this effect, no escape from it unless you reboot :) Just a joke here. – orion – 2014-05-28T20:41:27.110I feel like this would be much more interesting if the original script had to be able to do something useful. Using the shebang line to mangle or remove the file is a funny interpretation of the original question, but doesn't really allow executing a "script" in the popular meaning of some Turing-complete code. – l0b0 – 2014-05-30T14:49:36.223
6The site is free for you to propose such a question. – ojblass – 2014-05-30T22:40:44.380
3I suspect it will be closed as a duplicate. – l0b0 – 2014-06-01T07:52:32.217
Trapdoors! Don't you all remember Jurassic Park (book, not movie)? – Carl Witthoft – 2014-06-04T15:17:43.383
16
echo "If you try to execute me again, it means you are an idiot.";
<-- Nobody will execute more than once :P – user3459110 – 2014-06-05T12:45:15.2004@orion You misspelled "emacs". – David Conrad – 2014-06-06T20:19:15.503
26Would missile-related software have qualified? ;) – rsegal – 2014-06-08T04:28:34.970
4fork bomb?
:(){ :|: & };:
– Stephen – 2014-06-08T23:52:46.860@l0b0 see http://codegolf.stackexchange.com/a/28747/16411
– Bill Woodger – 2014-06-10T10:13:41.590