From 97bc22c273c5621c94072bd96e75aef84837a943 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 22 Feb 2024 21:18:50 -0500 Subject: bugfixes in SOURCES.bash --- bash/SOURCES.bash | 26 ++++++++++++++------------ 1 file 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() { if [[ $1 != */* ]] && ( - command -v base64_embedded_source__"$1" || + command -v base64_embedded_source__"$1" >/dev/null || [ -f src/"$1" ] - ) >&2 # >/dev/null + ) then rewrite_self \ "$1" \ @@ -23,7 +23,7 @@ denominate_function() local func_output_b64encoded output_hash read -r -d '' \ func_output_b64encoded \ - < <(base64) || [ "${func_output_b64encoded}" ] + < <(base64) || [ "$func_output_b64encoded" ] read output_hash _ \ < <(base64 -d <<< "$func_output_b64encoded" | sha256sum) [ ${#output_hash} = 64 ] || return @@ -44,18 +44,21 @@ rewrite_self() declare -n do_rewrite=do_rewrite${RANDOM} do_rewrite= - if [ -f "$2" ] + if ! command -v "$3" >/dev/null then + [ -f "$2" ] || return if [ -w "$0" ] then do_rewrite=$(mktemp) || return - source <(stdin_to_function "$3" < "$2" | + builtin source \ + <(stdin_to_function "$3" < "$2" | tee "$do_rewrite") || return else - source <(stdin_to_function "$3" < "$2") || return + builtin source \ + <(stdin_to_function "$3" < "$2") || return fi + command -v "$3" >/dev/null || return fi - command -v "$3" >/dev/null || return builtin source <("$3") "${@:4}" || return @@ -85,22 +88,21 @@ $(base64 && echo .) . } -embed_source() -{ - stdin_to_function "base64_embedded_source__${1}" "${@:2}" -} - print_test_script_for_SOURCES.bash() { cat <<. #!/bin/bash source SOURCES.bash +source SOURCES.bash source rpc.bash r() { + : base64_embedded_source__SOURCES.bash : base64_embedded_source__rpc.bash : base64_embedded_source__dependencies.bash + source SOURCES.bash source rpc.bash + BASH_RPC_REMOTE_DEST=localhost remote_run_function uptime } BASH_RPC_REMOTE_DEST=localhost \\ remote_run_function \\ -- cgit v1.2.3