ao-mud is a spellbook of well-commented atomic bash scripts that each do one thing. we are building semantic building blocks for an autonomously-evolving digital spellcasting language.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
729 B

#!/usr/bin/env sh
# This magical spell reveals the maximum length of a list of strings.
# Usage: cast_max_length string1 string2 ...
# Define the function to calculate the maximum length of the given strings
max_length() {
# Initialize the maximum length to 0
max_length=0
# Loop through the arguments and calculate the maximum length
for string in "$@"; do
length=${#string}
if [ $length -gt $max_length ]; then
max_length=$length
fi
done
# Output the maximum length
echo "Maximum length: $max_length"
}
# Check if the script is being called from another script
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
# If not, call the function and pass it the command line arguments
max_length "$@"
fi