diff options
author | Canop <cano.petrole@gmail.com> | 2021-05-11 07:57:44 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-05-11 07:57:44 +0200 |
commit | 341d956d9ffda33bb4f088bde14dd379db749159 (patch) | |
tree | b269ebd64c628016b02c422b6900237c10794fc0 | |
parent | bf7a12865e27a6310709fa53da3da922cd887169 (diff) | |
parent | b0ece3909e9ebd7cb9d233bb46b99cac952f8198 (diff) |
Merge branch 'bash-fn' of https://github.com/vladimyr/broot into vladimyr-bash-fn
-rw-r--r-- | src/shell_install/bash.rs | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/shell_install/bash.rs b/src/shell_install/bash.rs index 249172c..00cd268 100644 --- a/src/shell_install/bash.rs +++ b/src/shell_install/bash.rs @@ -38,23 +38,17 @@ const BASH_FUNC: &str = r#" # It's needed because some shell commands, like `cd`, # have no useful effect if executed in a subshell. function br { - f=$(mktemp) - ( - set +e - broot --outcmd "$f" "$@" - code=$? - if [ "$code" != 0 ]; then - rm -f "$f" - exit "$code" - fi - ) - code=$? - if [ "$code" != 0 ]; then - return "$code" + local cmd cmd_file code + cmd_file=$(mktemp) + if broot --outcmd "$cmd_file" "$@"; then + cmd=$(<"$cmd_file") + rm -f "$cmd_file" + eval "$cmd" + else + code=$? + rm -f "$cmd_file" + return "$code" fi - d=$(<"$f") - rm -f "$f" - eval "$d" } "#; |