Fix awk error in tasklib.sh by renaming 'func' variable

The variable name 'func' is a reserved builtin in gawk, causing
errors when running `./task help`. Renamed to 'funcname' to avoid
the conflict.
This commit is contained in:
Sebastian Lenzlinger 2025-06-18 00:41:35 +02:00
parent 854126bb4b
commit fad2c8b5dc

View File

@ -13,7 +13,7 @@ get_function_usage() {
local file="${2:-$0}"
# Get the function definition and extract Usage: comments
awk -v func="$func_name" '
awk -v funcname="$func_name" '
/^[[:space:]]*'"$func_name"'[[:space:]]*\(\)/ {
in_func = 1
next
@ -37,14 +37,14 @@ show_task_help() {
echo "================"
echo
for func in $func_list; do
for funcname in $func_list; do
# Skip internal functions and the help function itself
if [[ ! "$func" =~ ^(_|show_task_help|list_functions|get_function_usage) ]]; then
local usage=$(get_function_usage "$func" "$file")
if [[ ! "$funcname" =~ ^(_|show_task_help|list_functions|get_function_usage) ]]; then
local usage=$(get_function_usage "$funcname" "$file")
if [[ -n "$usage" ]]; then
printf "%-30s %s\n" "$func" "- $usage"
printf "%-30s %s\n" "$funcname" "- $usage"
else
printf "%-30s\n" "$func"
printf "%-30s\n" "$funcname"
fi
fi
done