Skip to content

Instantly share code, notes, and snippets.

@cypher
Created December 7, 2009 16:39
Show Gist options
  • Save cypher/250917 to your computer and use it in GitHub Desktop.
Save cypher/250917 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
script = <<-BASH
if [ ! -n "${foobar+x}" ]; then \
echo "foobar is unset"; \
elif [[ ${!foobar[@]} ]]; then \
if [[ $foobar ]]; then \
echo "foobar is set"; \
else \
echo "foobar is set, but empty"; \
fi \
fi
BASH
ENV['foobar'] = nil
system('/bin/bash', '-c', script)
ENV['foobar'] = ''
system('/bin/bash', '-c', script)
ENV['foobar'] = 'foobar'
system('/bin/bash', '-c', script)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment