Skip to content

Commit d22181f

Browse files
committed
fix(from env): replace \n
Many .env (most?) replace `\n`. Follow the standard of properly replacing with literal newline character.
1 parent b42f2bd commit d22181f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

modules/formats/from-env.nu

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
# may be used like this: open .env | load-env
33
# works with quoted and unquoted .env files
44
def "from env" []: string -> record {
5-
lines
5+
lines
66
| split column '#' # remove comments
7-
| get column1
7+
| get column1
88
| parse "{key}={value}"
9-
| str trim value -c '"' # unquote values
9+
| update value {
10+
str trim -c '"' | # unquote values
11+
str replace -a "\\n" "\n" # replace `\n` with newline char
12+
}
1013
| transpose -r -d
1114
}

0 commit comments

Comments
 (0)