summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-08-24 07:51:56 -0400
committerAndrew Cady <d@jerkface.net>2023-08-24 07:51:56 -0400
commit6312004af0bc5d488e6dd1d6ec7744743138c649 (patch)
treeef90673a907d130135ea5ab7fc28531314648480
parent5f8d82c9078b3076d7009bd8aa98e10ea3ac70a3 (diff)
minor improvements
-rw-r--r--src/rpc.bash15
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
17read_len() 17read_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
25read_remote_command() 23read_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
32remote_run_shell_script_stdin() 30remote_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}