From 855f5304482b1b04bedb686ba0994fbf23b5a510 Mon Sep 17 00:00:00 2001 From: Jacob Strieb Date: Fri, 15 Nov 2024 20:13:56 -0500 Subject: [PATCH] Try shasum if no sha256sum binary (address #1) --- just_sh/convert.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/just_sh/convert.py b/just_sh/convert.py index d562b9b..c90b6be 100644 --- a/just_sh/convert.py +++ b/just_sh/convert.py @@ -270,6 +270,8 @@ def expression_to_string(expression: ExpressionType, depth: int = 0) -> str: "sha256_file": r"""sha256_file() { if type sha256sum > /dev/null 2>&1; then sha256sum --binary "${1}" | cut -d ' ' -f 1 + elif type shasum > /dev/null 2>&1; then + shasum --algorithm 256 --binary "${1}" | cut -d ' ' -f 1 elif type python3 > /dev/null 2>&1; then python3 -c 'from hashlib import sha256; import sys; print(sha256(sys.stdin.buffer.read()).hexdigest())' \ < "${1}" @@ -285,6 +287,8 @@ def expression_to_string(expression: ExpressionType, depth: int = 0) -> str: "sha256": r"""sha256() { if type sha256sum > /dev/null 2>&1; then printf "%s" "${1}" | sha256sum --binary | cut -d ' ' -f 1 + if type shasum > /dev/null 2>&1; then + printf "%s" "${1}" | shasum --algorithm 256 --binary | cut -d ' ' -f 1 elif type python3 > /dev/null 2>&1; then printf "%s" "${1}" | \ python3 -c 'from hashlib import sha256; import sys; print(sha256(sys.stdin.buffer.read()).hexdigest())'