summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-08-26 11:36:46 -0400
committerAndrew Cady <d@jerkface.net>2023-08-26 11:36:46 -0400
commit0746a110202ad67bf771e4d6072730c8a5c4744f (patch)
tree38b4deabbf8c89617d12257e9d8f05c9d2188784
parentd48d4672067330ab4c74c6200779fcee81ec0e6d (diff)
cleaning and shit
-rw-r--r--src/rpc.bash55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/rpc.bash b/src/rpc.bash
index ea72b3d..99ea7e2 100644
--- a/src/rpc.bash
+++ b/src/rpc.bash
@@ -95,14 +95,10 @@ bash_rpc_run_function_simple()
95 "$@" 95 "$@"
96} 96}
97 97
98remote_run_function_notty() 98remote_run_stage1_notty()
99{ 99{
100 main=$1 100 stage2_source=$1
101 funcs=$(recursive_dependencies "$main") 101 shift
102 stage2_source=$(
103 declare -f $funcs
104 printf '"$@"\n'
105 )
106 { 102 {
107 printf '%s' "$stage2_source" 103 printf '%s' "$stage2_source"
108 cat 104 cat
@@ -119,35 +115,42 @@ read_stdin()
119 read -r -N2147483647 || [ "$REPLY" ] 115 read -r -N2147483647 || [ "$REPLY" ]
120} 116}
121 117
122remote_run_function_tty() 118tty_stage1()
123{ 119{
124 main=$1 120 local SET_TERM="$1"
125 funcs=$(recursive_dependencies "$main") 121 read_stdin <<END
126 stage2_source=$( 122 set -- "\$TERM" "\$@"
127 declare -f $funcs 123 TERM=${SET_TERM@Q}
128 printf 'TERM=%s\n' "${TERM@Q}" 124 source <(echo shift; printf '%s' "\$1")
129 printf '"$@"\n'
130 )
131 (
132 TERM="$stage2_source"
133 export TERM
134 read_stdin <<'END'
135 rpc=$TERM
136 TERM=screen
137 source <(printf '%s' "$rpc")
138END 125END
139 bash_rpc_with_ssh_option -t \ 126 printf '%s' "$REPLY"
127}
128
129remote_run_stage1_tty()
130{
131 stage2_source=$1
132 stage1_source=$(tty_stage1 "$TERM")
133 shift
134 (
135 TERM="$stage2_source" \
136 bash_rpc_with_ssh_option -t \
140 bash_rpc_remote_run_script \ 137 bash_rpc_remote_run_script \
141 "$REPLY" "$@" 138 "$stage1_source" "$@"
142 ) 139 )
143} 140}
144 141
145remote_run_function() 142remote_run_function()
146{ 143{
144 main=$1
145 funcs=$(recursive_dependencies "$main")
146 stage2_source=$(
147 declare -f $funcs
148 printf '"$@"\n'
149 )
147 if [ -t 0 ] 150 if [ -t 0 ]
148 then 151 then
149 remote_run_function_tty "$@" 152 remote_run_stage1_tty "$stage2_source" "$@"
150 else 153 else
151 remote_run_function_notty "$@" 154 remote_run_stage1_notty "$stage2_source" "$@"
152 fi 155 fi
153} 156}