summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@vps-18a7a2b7.vps.ovh.ca>2024-02-22 21:18:50 -0500
committerroot <root@vps-18a7a2b7.vps.ovh.ca>2024-02-22 21:18:50 -0500
commit97bc22c273c5621c94072bd96e75aef84837a943 (patch)
tree1856cd7153b09d67deb14802e7a199afb28029bb
parentdbec1d221b1f309f1e8981883d1d03229ba06028 (diff)
bugfixes in SOURCES.bash
-rw-r--r--bash/SOURCES.bash26
1 files changed, 14 insertions, 12 deletions
diff --git a/bash/SOURCES.bash b/bash/SOURCES.bash
index 609e98e..2f06c68 100644
--- a/bash/SOURCES.bash
+++ b/bash/SOURCES.bash
@@ -3,9 +3,9 @@ source()
3{ 3{
4 if [[ $1 != */* ]] && 4 if [[ $1 != */* ]] &&
5 ( 5 (
6 command -v base64_embedded_source__"$1" || 6 command -v base64_embedded_source__"$1" >/dev/null ||
7 [ -f src/"$1" ] 7 [ -f src/"$1" ]
8 ) >&2 # >/dev/null 8 )
9 then 9 then
10 rewrite_self \ 10 rewrite_self \
11 "$1" \ 11 "$1" \
@@ -23,7 +23,7 @@ denominate_function()
23 local func_output_b64encoded output_hash 23 local func_output_b64encoded output_hash
24 read -r -d '' \ 24 read -r -d '' \
25 func_output_b64encoded \ 25 func_output_b64encoded \
26 < <(base64) || [ "${func_output_b64encoded}" ] 26 < <(base64) || [ "$func_output_b64encoded" ]
27 read output_hash _ \ 27 read output_hash _ \
28 < <(base64 -d <<< "$func_output_b64encoded" | sha256sum) 28 < <(base64 -d <<< "$func_output_b64encoded" | sha256sum)
29 [ ${#output_hash} = 64 ] || return 29 [ ${#output_hash} = 64 ] || return
@@ -44,18 +44,21 @@ rewrite_self()
44 declare -n do_rewrite=do_rewrite${RANDOM} 44 declare -n do_rewrite=do_rewrite${RANDOM}
45 do_rewrite= 45 do_rewrite=
46 46
47 if [ -f "$2" ] 47 if ! command -v "$3" >/dev/null
48 then 48 then
49 [ -f "$2" ] || return
49 if [ -w "$0" ] 50 if [ -w "$0" ]
50 then 51 then
51 do_rewrite=$(mktemp) || return 52 do_rewrite=$(mktemp) || return
52 source <(stdin_to_function "$3" < "$2" | 53 builtin source \
54 <(stdin_to_function "$3" < "$2" |
53 tee "$do_rewrite") || return 55 tee "$do_rewrite") || return
54 else 56 else
55 source <(stdin_to_function "$3" < "$2") || return 57 builtin source \
58 <(stdin_to_function "$3" < "$2") || return
56 fi 59 fi
60 command -v "$3" >/dev/null || return
57 fi 61 fi
58 command -v "$3" >/dev/null || return
59 62
60 builtin source <("$3") "${@:4}" || return 63 builtin source <("$3") "${@:4}" || return
61 64
@@ -85,22 +88,21 @@ $(base64 && echo .)
85. 88.
86} 89}
87 90
88embed_source()
89{
90 stdin_to_function "base64_embedded_source__${1}" "${@:2}"
91}
92
93print_test_script_for_SOURCES.bash() 91print_test_script_for_SOURCES.bash()
94{ 92{
95 cat <<. 93 cat <<.
96#!/bin/bash 94#!/bin/bash
97source SOURCES.bash 95source SOURCES.bash
96source SOURCES.bash
98source rpc.bash 97source rpc.bash
99r() 98r()
100{ 99{
100 : base64_embedded_source__SOURCES.bash
101 : base64_embedded_source__rpc.bash 101 : base64_embedded_source__rpc.bash
102 : base64_embedded_source__dependencies.bash 102 : base64_embedded_source__dependencies.bash
103 source SOURCES.bash
103 source rpc.bash 104 source rpc.bash
105 BASH_RPC_REMOTE_DEST=localhost remote_run_function uptime
104} 106}
105BASH_RPC_REMOTE_DEST=localhost \\ 107BASH_RPC_REMOTE_DEST=localhost \\
106 remote_run_function \\ 108 remote_run_function \\