dotfiles/.local/lib/get-env-var.rb

14 lines
217 B
Ruby
Raw Permalink Normal View History

2023-02-07 21:21:45 -07:00
# frozen_string_literal: true
if !defined?(@var_name)
$stderr.puts "`var_name` is undefined"
exit 2
end
if !ENV.key?(@var_name)
$stderr.puts "#{@var_name} is not set"
exit 1
end
printf "%s", ENV[@var_name]