fixup
This commit is contained in:
parent
48c241b383
commit
4529bebeab
26
src/sum.sh
26
src/sum.sh
|
@ -1,9 +1,18 @@
|
|||
# /etc/profile.d/sum.sh
|
||||
|
||||
# Ensure the script is sourced
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" || "${(%):-%N}" == "$0" ]]; then
|
||||
echo "This script should be sourced, not executed."
|
||||
exit 1
|
||||
# Ensure the script is sourced, not executed
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
# For zsh
|
||||
if [[ "${(%):-%x}" == "$0" ]]; then
|
||||
echo "This script should be sourced, not executed."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
# For bash
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
echo "This script should be sourced, not executed."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Function to generate SHA-256 hashes for .sh files in a given directory
|
||||
|
@ -16,15 +25,10 @@ generate_sha256_hashes() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
# Determine the command to use for calculating SHA-256
|
||||
local hash_cmd
|
||||
# Use shasum by default, and fallback to sha256sum if available
|
||||
local hash_cmd="shasum -a 256"
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
hash_cmd="sha256sum"
|
||||
elif command -v shasum >/dev/null 2>&1; then
|
||||
hash_cmd="shasum -a 256"
|
||||
else
|
||||
echo "Neither sha256sum nor shasum command is available."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Loop through all .sh files in the directory
|
||||
|
|
Loading…
Reference in New Issue