Skip to content

Commit 12e6933

Browse files
authored
Module handles exitcode 1 from bash-env-json (#37)
I'm no longer updating the plugin though, that is deprecated and will be removed soon.
1 parent 87a4ad9 commit 12e6933

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

bash-env.nu

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@ export def main [
1616
[]
1717
}
1818

19-
let raw = ($in | str join "\n") | bash-env-json ...($fn_args ++ $path_args) | from json
19+
let raw = ($in | str join "\n") | bash-env-json ...($fn_args ++ $path_args) | complete
20+
let raw_json = $raw.stdout | from json
2021

21-
let error = $raw | get -i error
22+
let error = $raw_json | get -i error
2223
if $error != null {
2324
error make { msg: $error }
25+
} else if $raw.exit_code != 0 {
26+
error make { msg: $"unexpected failure from bash-env-json ($raw.stderr)" }
2427
}
2528

2629
if ($export | is-not-empty) {
2730
print "warning: --export is deprecated, use --shellvars(-s) instead"
28-
let exported_shellvars = ($raw.shellvars | select -i ...$export)
29-
$raw.env | merge ($exported_shellvars)
31+
let exported_shellvars = ($raw_json.shellvars | select -i ...$export)
32+
$raw_json.env | merge ($exported_shellvars)
3033
} else if $shellvars or ($fn | is-not-empty) {
31-
$raw
34+
$raw_json
3235
} else {
33-
$raw.env
36+
$raw_json.env
3437
}
3538
}

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)