From 6312004af0bc5d488e6dd1d6ec7744743138c649 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 24 Aug 2023 07:51:56 -0400 Subject: minor improvements --- src/rpc.bash | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/rpc.bash b/src/rpc.bash index 91292cd..644df95 100644 --- a/src/rpc.bash +++ b/src/rpc.bash @@ -16,17 +16,15 @@ extract_words() read_len() { - [ "$1" -gt 0 ] REPLY= - read -r -N"$1" - [ "$REPLY" ] + [ "$1" -gt 0 ] && read -r -N"$1" && [ "$REPLY" ] } read_remote_command() { read_len "$1" shift - remote_command=(bash -c ${REPLY@Q} bash "${@@Q}") + remote_command=(bash -c "${REPLY@Q}" bash "${@@Q}") } remote_run_shell_script_stdin() @@ -48,9 +46,11 @@ remote_run_shell_script_arg1() set -- "${#script}" "$@" if test -t 0 && test -t 1 then - printf '%s' "$script" | remote_run_shell_script_tty "$@" + printf '%s' "$script" | + remote_run_shell_script_tty "$@" else - cat <(printf '%s' "$script") - | remote_run_shell_script_stdin "$@" + cat <(printf '%s' "$script") - | + remote_run_shell_script_stdin "$@" fi } @@ -93,7 +93,8 @@ remote_run_function() read -N2147483647 -r script < <( declare -f $funcs printf '%s "$@";\n' "$main" - ) || [ "$script" ] + ) || true + [ "$script" ] remote_run_shell_script_arg1 "$script" "$@" } -- cgit v1.2.3