Last active
May 31, 2017 07:42
-
-
Save mvidner/2924e087d809efcc797c1cc6b791b0e2 to your computer and use it in GitHub Desktop.
What do these files do when you run them with Ruby?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Ruby Gotcha Quiz, by Martin Vidner | |
# Aimed at people who have written something in Ruby already | |
def command(s) | |
system(s) | |
end | |
command "echo A" | |
command <<EOS | |
echo B | |
EOS | |
# The 1st program ends here. Will it work? | |
command = "echo C" | |
command "echo D" | |
# The 2nd program includes the 1st program and ends here. Will it work? | |
command <<EOS | |
echo E | |
EOS | |
# The 3rd program includes the above and ends here. Will it work? | |
command <<EOS | |
ls -l -a | |
EOS | |
# The 4th program includes the above and ends here. Will it work? | |
# If a program does not work, what kind of error occurs? | |
# - syntax error, the interpreter/compiler complains before running it | |
# - runtime error, it aborts while running | |
# - logic error, it runs without aborting but does something else than intended | |
# - style error, it works but your team will not accept it into the shared repo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
def command(s) | |
system(s) | |
end | |
command "echo A" | |
command <<EOS | |
echo B | |
EOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
def command(s) | |
system(s) | |
end | |
command "echo A" | |
command <<EOS | |
echo B | |
EOS | |
command = "echo C" | |
command "echo D" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
def command(s) | |
system(s) | |
end | |
command "echo A" | |
command <<EOS | |
echo B | |
EOS | |
command = "echo C" | |
command "echo D" | |
command <<EOS | |
echo E | |
EOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
def command(s) | |
system(s) | |
end | |
command "echo A" | |
command <<EOS | |
echo B | |
EOS | |
command = "echo C" | |
command "echo D" | |
command <<EOS | |
echo E | |
EOS | |
command <<EOS | |
ls -l -a | |
EOS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@bmwiedemann this is the problem that we hit when we catted the chef files in crowbar-openstack