diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc.bash | 15 |
1 files changed, 8 insertions, 7 deletions
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() | |||
16 | 16 | ||
17 | read_len() | 17 | read_len() |
18 | { | 18 | { |
19 | [ "$1" -gt 0 ] | ||
20 | REPLY= | 19 | REPLY= |
21 | read -r -N"$1" | 20 | [ "$1" -gt 0 ] && read -r -N"$1" && [ "$REPLY" ] |
22 | [ "$REPLY" ] | ||
23 | } | 21 | } |
24 | 22 | ||
25 | read_remote_command() | 23 | read_remote_command() |
26 | { | 24 | { |
27 | read_len "$1" | 25 | read_len "$1" |
28 | shift | 26 | shift |
29 | remote_command=(bash -c ${REPLY@Q} bash "${@@Q}") | 27 | remote_command=(bash -c "${REPLY@Q}" bash "${@@Q}") |
30 | } | 28 | } |
31 | 29 | ||
32 | remote_run_shell_script_stdin() | 30 | remote_run_shell_script_stdin() |
@@ -48,9 +46,11 @@ remote_run_shell_script_arg1() | |||
48 | set -- "${#script}" "$@" | 46 | set -- "${#script}" "$@" |
49 | if test -t 0 && test -t 1 | 47 | if test -t 0 && test -t 1 |
50 | then | 48 | then |
51 | printf '%s' "$script" | remote_run_shell_script_tty "$@" | 49 | printf '%s' "$script" | |
50 | remote_run_shell_script_tty "$@" | ||
52 | else | 51 | else |
53 | cat <(printf '%s' "$script") - | remote_run_shell_script_stdin "$@" | 52 | cat <(printf '%s' "$script") - | |
53 | remote_run_shell_script_stdin "$@" | ||
54 | fi | 54 | fi |
55 | } | 55 | } |
56 | 56 | ||
@@ -93,7 +93,8 @@ remote_run_function() | |||
93 | read -N2147483647 -r script < <( | 93 | read -N2147483647 -r script < <( |
94 | declare -f $funcs | 94 | declare -f $funcs |
95 | printf '%s "$@";\n' "$main" | 95 | printf '%s "$@";\n' "$main" |
96 | ) || [ "$script" ] | 96 | ) || true |
97 | [ "$script" ] | ||
97 | 98 | ||
98 | remote_run_shell_script_arg1 "$script" "$@" | 99 | remote_run_shell_script_arg1 "$script" "$@" |
99 | } | 100 | } |