mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
fix "from env" newline handling (#1021)
Many (at least the ones I have encountered) env loaders replace "\n" with a literal newline character when loading an env variable. I need this change in my personal config and I think others would also prefer this default.
This commit is contained in:
parent
b42f2bd5c1
commit
e245718d30
1 changed files with 8 additions and 3 deletions
|
@ -6,6 +6,11 @@ def "from env" []: string -> record {
|
|||
| split column '#' # remove comments
|
||||
| get column1
|
||||
| parse "{key}={value}"
|
||||
| str trim value -c '"' # unquote values
|
||||
| update value {
|
||||
str trim -c '"' | # unquote values
|
||||
str replace -a "\\n" "\n" # replace `\n` with newline char
|
||||
str replace -a "\\r" "\r" # replace `\r` with carriage return
|
||||
str replace -a "\\t" "\t" # replace `\t` with tab
|
||||
}
|
||||
| transpose -r -d
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue