Reputation: 7097
Inspired by this I now do
hostname = %x{hostname}
if ['staging', 'prod', 'jlpc'].include? hostname
puts "yes"
end
My Linux hostname is jlpc
but it doesn't print out yes
.
Why doesn't this work?
Upvotes: 1
Views: 59
Reputation: 879
%x{hostname}
# => "hostname\n"
Solution:
puts "yes" if ['staging', 'prod', 'jlpc'].include? hostname.chomp
Upvotes: 5
Reputation: 30071
I tried on my machine and that line appends a \n
at the end of my hostname. So, try
hostname = %x{hostname}.rstrip
Upvotes: 3