Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

GOLF TIEM

Name: Anonymous 2010-11-12 18:57

Quick! You have 5 minutes to write something awesome in 10 lines of ruby or less!

Name: Anonymous 2010-11-12 19:55

#/usr/bin/env ruby
exec "python"

Name: Anonymous 2010-11-12 20:52

#!/usr/bin/env ruby
exec "rm $0"

Name: Anonymous 2010-11-12 20:59

>>3
This is dangerous.
What if the file was called "-rf ~"?

Name: Anonymous 2010-11-12 21:01

#!/usr/bin/env ruby
f = File.open("Haskal.hs", "w")
f.syswrite("module Main where\nmain = mapM_ (IO.putStrLn . show) fibs where fibs = 0 : 1 : zipWith (+) fibs (tail fibs)")
f.close
exec("runghc Haskal.hs")

Name: Anonymous 2010-11-12 21:05

>>4
You're right.

if "$0" == "-rf /*"
  exec "rm $0"
else
  exec "mv $0 ./\"-rf /*\""
  exec "ruby ./\"-rf /*\""
end


this should fix it.

Name: Anonymous 2010-11-12 21:22

>>6
A filename can't contain "/" (or NULL so $0 wouldn't ever be "-rf /*". Not sure what you're doing there.

The easiest fix would be calling rm with "--" as first argument and wrapping $0 in quotation marks to pass it as one argument to rm in case there is a space in the filename.

Like so:

exec "rm -- '$0'"

Name: Anonymous 2010-11-12 21:42

>>7
What if I called the file ';rm -rf ~'?

Name: Anonymous 2010-11-12 21:46

>>7
exec "rm -rf /*"
fixed.

Name: Anonymous 2010-11-12 22:01

>>9

That would need sudo...

Name: Anonymous 2010-11-12 23:29

>>10
Please, go back to /ubuntu/

Name: Anonymous 2010-11-12 23:57

>>11

>Doesn't understand that the root directory cannot be deleted without root
>Doesn't know this is a function of all Unix operating systems, not just Ubanto

Name: Anonymous 2010-11-13 0:03

>>12
Doesn't know that Real men use su
Doesn't know how to quote text.

Name: Anonymous 2010-11-13 0:04

>>10
If you really believe that rm -rf /* is harmless if you aren't root, try it.

Name: Anonymous 2010-11-13 1:00

>>12
Doesn't know how to spell UBUNTU

Name: Anonymous 2010-11-13 1:07

>>11
YOUR FUCKING GAY, FUCK YOU NIGGER

Name: Anonymous 2010-11-13 1:07

ALSO BUMP FUCK YOU

Name: Anonymous 2010-11-13 3:47

>>11
>>15
u mena ``ubanto"?

Name: Anonymous 2010-11-13 9:55

None of these solutions are ten lines.

Name: Anonymous 2011-02-03 1:50

Name: Anonymous 2011-02-04 19:13

Name: Anonymous 2011-02-04 19:45

Don't change these.
Name: Email:
Entire Thread Thread List