summaryrefslogtreecommitdiff
path: root/src/rpc.main2.bash
blob: ad5e15bcf3ae8353f70808ccf6cf29ebf8a86a55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
set -e
set -o pipefail
case "$0" in
        [^/]* ) PATH=$(realpath -e "$(dirname "$BASH_SOURCE")"):$PATH ;;
esac
source rpc.bash

main()
{
        funcs=$(find_local_only_functions "$@" </dev/null | xargs)
        [ ! "$funcs" ] || printf 'Local-only functions (main2): %s\n' "$funcs" >&2
}

find_local_only_functions()
{
        remote_commands=($(remote_run_function all_commands | sort -u))
        printf 'remote commands: %d\n' ${#remote_commands[@]} >&2
        intersection <(extract_words < "$BASH_SOURCE") \
                     <(difference <(all_commands) \
                                  <(printf '%s\n' "${remote_commands[@]}"))
}

all_commands()
{
        : main
        compgen -A command | sort -u
}

main "$@"