Only subset of shell functionality is supported
Author: graywolf-at-workCreated Apr 15, 2021Updated Apr 20, 2021
Steps to reproduce
I've run into an issue today, when under impression that dotenv (since it states that the file can be sources into shell) supports basically POSIX shell. However, that was actually not so. Main issue is not necessarily the lack of the functionality (it is and I had to stop using dotenv in our CI), but that the unsupported syntax is just silently ignored.
+$ ls
env Gemfile Gemfile.lock test.rb test.sh
+$ cat env
X=${Y-Z}
export X
+$ env | grep ^Y=
+$ cat Gemfile
source 'https://rubygems.org' do
gem 'dotenv'
end
+$ cat Gemfile.lock
GEM
specs:
GEM
remote: https://rubygems.org/
specs:
dotenv (2.7.6)
PLATFORMS
x86_64-linux
DEPENDENCIES
dotenv!
BUNDLED WITH
2.2.16
+$ cat test.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
$-v = true
require('dotenv')
Dotenv.load('env')
pp(ENV['X'])
+$ cat test.sh
#!/bin/sh
. ./env
echo $X
+$ bundle exec ./test.rb
"-Z}"
+$ ./test.sh
Z
Assuming we would be willing to invoke actual shell, I believe it is possible to support full POSIX range of features. Assuming that would be accepted, I'm willing to work on such addition. Would it be merged?
Expected behavior
+$ bundle exec ./test.rb
"Z"Actual behavior
+$ bundle exec ./test.rb
"-Z}"System configuration
dotenv version:
2.7.6
Rails version:
N/A
Ruby version:
2.7.2
Source: bkeepers/dotenv