Skip to content

Commit af28677

Browse files
committed
Put the regex splitter in a comment, use split row char sep instead as default
1 parent cea99eb commit af28677

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

nu-hooks/nu-hooks/direnv/config.nu

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
direnv export json | from json | default {} | load-env
2626
# Direnv outputs $PATH as a string, but nushell silently breaks if isn't a list-like table.
27-
# The following behemoth of Nu code turns this into nu's format while following the standards of how to handle quotes
28-
$env.PATH = $env.PATH | parse --regex ('' + `((?:(?:"(?:(?:\\[\\"])|.)*?")|(?:'.*?')|[^` + (char env_sep) + `]*)*)`) | each {|x| $x.capture0 | parse --regex `(?:"((?:(?:\\"|.))*?)")|(?:'(.*?)')|([^'"]*)` | each {|y| if ($y.capture0 != "") { $y.capture0 | str replace -ar `\\([\\"])` `$1` } else if ($y.capture1 != "") { $y.capture1 } else $y.capture2 } | str join }
27+
# The following behemoth of Nu code turns this into nu's format while following the standards of how to handle quotes, use it if you need quote handling instead of the line below it:
28+
# $env.PATH = $env.PATH | parse --regex ('' + `((?:(?:"(?:(?:\\[\\"])|.)*?")|(?:'.*?')|[^` + (char env_sep) + `]*)*)`) | each {|x| $x.capture0 | parse --regex `(?:"((?:(?:\\"|.))*?)")|(?:'(.*?)')|([^'"]*)` | each {|y| if ($y.capture0 != "") { $y.capture0 | str replace -ar `\\([\\"])` `$1` } else if ($y.capture1 != "") { $y.capture1 } else $y.capture2 } | str join }
29+
$env.PATH = $env.PATH | split row (char env_sep)
2930
}

0 commit comments

Comments
 (0)