diff options
author | Andrew Cady <d@jerkface.net> | 2023-08-27 11:55:32 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2023-08-27 11:55:32 -0400 |
commit | 17e91005ccedc355cb213fda0cbbe674a847ea85 (patch) | |
tree | 49644eff7c5d88ea9e84e1ad530688a03d54c595 /src/rpc.main.bash | |
parent | b01d26fcc596f46f20207f17636331f7916bb0ac (diff) |
YES
Diffstat (limited to 'src/rpc.main.bash')
-rw-r--r-- | src/rpc.main.bash | 47 |
1 files changed, 5 insertions, 42 deletions
diff --git a/src/rpc.main.bash b/src/rpc.main.bash index c34296e..21dc071 100644 --- a/src/rpc.main.bash +++ b/src/rpc.main.bash | |||
@@ -1,46 +1,10 @@ | |||
1 | #!/usr/bin/bash -e | 1 | #!/bin/bash |
2 | set -e | 2 | set -e |
3 | set -o pipefail | 3 | set -o pipefail |
4 | |||
5 | case "$0" in | 4 | case "$0" in |
6 | [^/]* ) PATH=$(realpath -e "$(dirname "$BASH_SOURCE")"):$PATH ;; | 5 | [^/]* ) PATH=$(realpath -e "$(dirname "$BASH_SOURCE")"):$PATH ;; |
7 | esac | 6 | esac |
8 | 7 | source rpc.bash | |
9 | . rpc.bash | ||
10 | |||
11 | our_main() | ||
12 | { | ||
13 | REMOTE_DEST=localhost | ||
14 | # main2 "$@" | ||
15 | main1 "$@" | ||
16 | } | ||
17 | |||
18 | main1() | ||
19 | { | ||
20 | # local -a BASH_RPC_SSH_OPTIONS=('-4' '-6' '-4') | ||
21 | with_ssh_options -4 -6 -4 -- \ | ||
22 | remote_run_function fudge "$@" | ||
23 | } | ||
24 | |||
25 | main2() | ||
26 | { | ||
27 | funcs=$(find_local_only_functions "$@" </dev/null | xargs) | ||
28 | [ ! "$funcs" ] || printf 'Local-only functions (main2): %s\n' "$funcs" >&2 | ||
29 | } | ||
30 | |||
31 | find_local_only_functions() | ||
32 | { | ||
33 | remote_commands=($(remote_run_function all_commands | sort -u)) | ||
34 | intersection <(extract_words < "$BASH_SOURCE") \ | ||
35 | <(difference <(all_commands) \ | ||
36 | <(printf '%s\n' "${remote_commands[@]}")) | ||
37 | } | ||
38 | |||
39 | all_commands() | ||
40 | { | ||
41 | : main2 | ||
42 | compgen -A command | sort -u | ||
43 | } | ||
44 | 8 | ||
45 | gudge() | 9 | gudge() |
46 | { | 10 | { |
@@ -48,12 +12,11 @@ gudge() | |||
48 | topic=${*@Q} | 12 | topic=${*@Q} |
49 | echo "Don't argue with me about ${topic:-punctuation}." | 13 | echo "Don't argue with me about ${topic:-punctuation}." |
50 | } | 14 | } |
51 | |||
52 | fudge() | 15 | fudge() |
53 | { | 16 | { |
54 | read -p "[$(hostname)] Name? " && gudge "$@" | 17 | read -p "[$(hostname)] Name? " && gudge "$@" |
55 | exit | 18 | exit |
56 | } | 19 | } |
57 | 20 | with_ssh_options -4 -- \ | |
58 | our_main "$@" | 21 | remote_run_function \ |
59 | 22 | fudge "$@" | |