From 6da26e6fae065b9167754ac9ca547c5001ac2e03 Mon Sep 17 00:00:00 2001 From: Simon Guest Date: Mon, 28 Oct 2024 18:14:22 +1300 Subject: [PATCH 1/2] Handle exitcode 1 from bash-env-json --- bash-env.nu | 7 +++++-- flake.lock | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bash-env.nu b/bash-env.nu index e714131..aeaf1e6 100644 --- a/bash-env.nu +++ b/bash-env.nu @@ -16,11 +16,14 @@ export def main [ [] } - let raw = ($in | str join "\n") | bash-env-json ...($fn_args ++ $path_args) | from json + let raw = ($in | str join "\n") | bash-env-json ...($fn_args ++ $path_args) | complete + let raw_json = $raw.stdout | from json - let error = $raw | get -i error + let error = $raw_json | get -i error if $error != null { error make { msg: $error } + } else if $raw.exit_code != 0 { + error make { msg: $"unexpected failure from bash-env-json ($raw.stderr)" } } if ($export | is-not-empty) { diff --git a/flake.lock b/flake.lock index ee4431c..e85304c 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ ] }, "locked": { - "lastModified": 1729393456, - "narHash": "sha256-EpGpe7P4DLETvKKgaZxDDaMptJnQMuMw9MSbegkIsI0=", + "lastModified": 1730091345, + "narHash": "sha256-kerVDH54dRGgrY83nQ8qJzDX3Od/ybw7Jhzp/Nb0cnk=", "owner": "tesujimath", "repo": "bash-env-json", - "rev": "5d7ec7e2e184e3f3f763050a40b862fd2599cef8", + "rev": "ba87ef4d764e48bafbd67d0cf770e8c7175c77c6", "type": "github" }, "original": { From 572f24bb898c8b66c34d333984d4a45d131aaa33 Mon Sep 17 00:00:00 2001 From: Simon Guest Date: Mon, 28 Oct 2024 18:17:10 +1300 Subject: [PATCH 2/2] raw renamed as raw_json --- bash-env.nu | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bash-env.nu b/bash-env.nu index aeaf1e6..1070477 100644 --- a/bash-env.nu +++ b/bash-env.nu @@ -28,11 +28,11 @@ export def main [ if ($export | is-not-empty) { print "warning: --export is deprecated, use --shellvars(-s) instead" - let exported_shellvars = ($raw.shellvars | select -i ...$export) - $raw.env | merge ($exported_shellvars) + let exported_shellvars = ($raw_json.shellvars | select -i ...$export) + $raw_json.env | merge ($exported_shellvars) } else if $shellvars or ($fn | is-not-empty) { - $raw + $raw_json } else { - $raw.env + $raw_json.env } }