Skip to content

Instantly share code, notes, and snippets.

@panzi
Last active June 2, 2024 00:08
Show Gist options
  • Save panzi/763957dfefe330867c5820d42288f05f to your computer and use it in GitHub Desktop.
Save panzi/763957dfefe330867c5820d42288f05f to your computer and use it in GitHub Desktop.
NodeJS now supports --load-env=.env, so you don't need the dotenv package anymore. However, the two ways of reading .env files disagree on parsing. (I remember docker-compose parses .env files different to dotenv, too, but haven't re-tested it now.)
VAR1
VAR2 =
VAR3 = "EGG BACON" "AND SPAM"
"VAR4"="BLUBB"
"VAR 4"=BLUBB
VAR5= "FOO BAR" # COMMENT
VAR6= FOO BAR # COMMNET
#VAR7=...
VAR8 = "FOO" "
BAR1=BAZ"
VAR9="FOO
BAR2=BAZ"
VAR10= "FOO BAR" BAZ BLA
11=111111
VAR12=#COMMENT
VAR13=TEXT#NO COMMENT
VAR14="#NO COMMNET"
VAR15= "#NO COMMNET"
VAR16="double quoted backslash:\\double quote:\"single quote:\'newline:\ntab:\tbackspace:\bformfeed:\fcarrige return:\runicode ä:\u00e4"
VAR17='single quoted backslash:\\double quote:\"single quote:\'newline:\ntab:\tbackspace:\bformfeed:\fcarrige return:\runicode ä:\u00e4'
VAR18=no quote backslash:\\double quote:\"single quote:\'newline:\ntab:\tbackspace:\bformfeed:\fcarrige return:\runicode ä:\u00e4
VAR19= FOO
VAR20=FOO\nBAR
VAR21="FOO" #"COMMENT"
VAR22=FOO \
BAR
VAR23="double\
quoted"
VAR24="double
quoted" BAZ
VAR25="double
quoted" #COMMENT
VAR26='single\'quoted'
VAR27='single''quoted'
VAR28='single-quoted' #COMMENT
VAR29='single-quoted'#COMMENT
VAR30='single-quoted' #COMMENT'
VAR31='single-quoted'#COMMENT'
VAR32='single
quoted'
VAR33=`back
ticks`
JSON1={"foo": "bar \n no quotes #"}
JSON2="{"foo": "bar \n double quotes #"}"
JSON3='{"foo": "bar \n single quotes #"}'
JSON4=`{"foo": "bar \n backticks #"}`
PRE_DEFINED=override
EOF="FOO
{
'11': '111111',
VAR2: '',
VAR3: 'EGG BACON" "AND SPAM',
VAR5: 'FOO BAR',
VAR6: 'FOO BAR',
VAR8: 'FOO" ',
BAR1: 'BAZ"',
VAR9: 'FOO\nBAR2=BAZ',
VAR10: '"FOO BAR" BAZ BLA',
VAR12: '',
VAR13: 'TEXT',
VAR14: '#NO COMMNET',
VAR15: '#NO COMMNET',
VAR16: `double quoted backslash:\\\\double quote:\\"single quote:\\'newline:\n` +
'tab:\\tbackspace:\\bformfeed:\\fcarrige return:\runicode ä:\\u00e4',
VAR17: `single quoted backslash:\\\\double quote:\\"single quote:\\'newline:\\ntab:\\tbackspace:\\bformfeed:\\fcarrige return:\\runicode ä:\\u00e4`,
VAR18: `no quote backslash:\\\\double quote:\\"single quote:\\'newline:\\ntab:\\tbackspace:\\bformfeed:\\fcarrige return:\\runicode ä:\\u00e4`,
VAR19: 'FOO',
VAR20: 'FOO\\nBAR',
VAR21: 'FOO',
VAR22: 'FOO \\',
VAR23: 'double\\\nquoted',
VAR24: '"double',
VAR25: 'double\nquoted',
VAR26: "single\\'quoted",
VAR27: "single''quoted",
VAR28: 'single-quoted',
VAR29: 'single-quoted',
VAR30: 'single-quoted',
VAR31: 'single-quoted',
VAR32: 'single\nquoted',
VAR33: 'back\nticks',
JSON1: '{"foo": "bar \\n no quotes',
JSON2: '"{"foo": "bar \n double quotes',
JSON3: '{"foo": "bar \\n single quotes #"}',
JSON4: '{"foo": "bar \\n backticks #"}',
PRE_DEFINED: 'not override',
EOF: '"FOO'
}
{
VAR2: '',
VAR3: '"EGG BACON" "AND SPAM"',
'"VAR4"': 'BLUBB',
'"VAR 4"': 'BLUBB',
VAR5: '"FOO BAR"',
VAR6: 'FOO BAR',
VAR8: '"FOO" "',
BAR1: 'BAZ"',
BAR2: 'BAZ"',
VAR10: '"FOO BAR" BAZ BLA',
VAR12: '',
VAR13: 'TEXT',
VAR14: '#NO COMMNET',
VAR15: '"',
VAR16: `double quoted backslash:\\\\double quote:\\"single quote:\\'newline:\\ntab:\\tbackspace:\\bformfeed:\\fcarrige return:\\runicode ä:\\u00e4`,
VAR17: `single quoted backslash:\\\\double quote:\\"single quote:\\'newline:\\ntab:\\tbackspace:\\bformfeed:\\fcarrige return:\\runicode ä:\\u00e4`,
VAR18: `no quote backslash:\\\\double quote:\\"single quote:\\'newline:\\ntab:\\tbackspace:\\bformfeed:\\fcarrige return:\\runicode ä:\\u00e4`,
VAR19: 'FOO',
VAR20: 'FOO\\nBAR',
VAR21: 'FOO" #"COMMENT',
VAR22: 'FOO \\',
VAR26: "single\\'quoted",
VAR27: "single''quoted",
VAR28: 'single-quoted',
VAR29: 'single-quoted',
VAR30: "single-quoted' #COMMENT",
VAR31: "single-quoted'#COMMENT",
JSON1: '{"foo": "bar \\n no quotes',
JSON2: '{"foo": "bar \\n double quotes #"}',
JSON3: '{"foo": "bar \\n single quotes #"}',
JSON4: '{"foo": "bar \\n backticks #"}',
PRE_DEFINED: 'not override'
}
{
VAR2: '',
VAR3: 'EGG BACON" "AND SPAM',
'"VAR4"': 'BLUBB',
'"VAR 4"': 'BLUBB',
VAR5: '"FOO BAR" # COMMENT',
VAR6: 'FOO BAR # COMMNET',
VAR8: 'FOO" ',
BAR1: 'BAZ"',
VAR9: '"FOO',
BAR2: 'BAZ"',
VAR10: '"FOO BAR" BAZ BLA',
VAR12: '#COMMENT',
VAR13: 'TEXT#NO COMMENT',
VAR14: '#NO COMMNET',
VAR15: '#NO COMMNET',
VAR16: `double quoted backslash:\\double quote:"single quote:'newline:\n` +
'tab:\tbackspace:\bformfeed:\fcarrige return:\runicode ä:ä',
VAR17: `single quoted backslash:\\\\double quote:\\"single quote:\\'newline:\\ntab:\\tbackspace:\\bformfeed:\\fcarrige return:\\runicode ä:\\u00e4`,
VAR18: `no quote backslash:\\\\double quote:\\"single quote:\\'newline:\\ntab:\\tbackspace:\\bformfeed:\\fcarrige return:\\runicode ä:\\u00e4`,
VAR19: 'FOO',
VAR20: 'FOO\\nBAR',
VAR21: 'FOO" #"COMMENT',
VAR22: 'FOO \\',
VAR23: '"double\\',
VAR24: '"double',
VAR25: '"double',
VAR26: "single\\'quoted",
VAR27: "single''quoted",
VAR28: "'single-quoted' #COMMENT",
VAR29: "'single-quoted'#COMMENT",
VAR30: "single-quoted' #COMMENT",
VAR31: "single-quoted'#COMMENT",
VAR32: "'single",
VAR33: '`back',
JSON1: '{"foo": "bar \\n no quotes #"}',
JSON2: '{"foo": "bar \n double quotes #"}',
JSON3: '{"foo": "bar \\n single quotes #"}',
JSON4: '`{"foo": "bar \\n backticks #"}`',
PRE_DEFINED: 'override',
EOF: '"FOO'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment