From e0b4cf23a9d9ea8ec71ea27ba90b9775c3834cdc Mon Sep 17 00:00:00 2001 From: Joshua Rogers Date: Fri, 12 Jan 2024 00:43:11 +0700 Subject: [PATCH] Fix old GNU-ism. --- Snake.nocomments.sh | 4 ++-- Snake.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Snake.nocomments.sh b/Snake.nocomments.sh index 52f927d..891c570 100644 --- a/Snake.nocomments.sh +++ b/Snake.nocomments.sh @@ -144,7 +144,7 @@ return 0 } function is_func_call() { for (i in funcs) { -if ($0 ~ "^[[:space:]]*" funcs[i]) { +if ($0 ~ "^ *" funcs[i]) { return 1 } } @@ -246,7 +246,7 @@ remove_function+="print_snake " remove_function+="gen_retried_interesting_dests " remove_function+="root_ssh_keys root_ssh_hostnames_dests root_ssh_hosts_dests" local_script="$(remove_functions "$THIS_SCRIPT" "$remove_function")" -local_script="$(printf "%s" "$local_script" | sed -e 's/^ *//' -e 's/^#.*$//' -e 's/[[:space:]]#.*//' -e '/^[[:space:]]*$/d')" +local_script="$(printf "%s" "$local_script" | sed -e 's/^ *//' -e 's/^#.*$//' -e 's/ while IFS= read -r line; do if [[ "$line" == *"EXTERNAL_MSG: KEY"* ]]; then root_ssh_keys["${line##* }"]=1 diff --git a/Snake.sh b/Snake.sh index f02341b..a3ae77a 100755 --- a/Snake.sh +++ b/Snake.sh @@ -329,7 +329,7 @@ remove_functions() { # [space][space][...] func_name function is_func_call() { for (i in funcs) { - if ($0 ~ "^[[:space:]]*" funcs[i]) { + if ($0 ~ "^ *" funcs[i]) { return 1 } } @@ -463,7 +463,7 @@ shape_script() { local_script="$(remove_functions "$THIS_SCRIPT" "$remove_function")" # Remove all comments and unnecessary white-spaces. - local_script="$(printf "%s" "$local_script" | sed -e 's/^ *//' -e 's/^#.*$//' -e 's/[[:space:]]#.*//' -e '/^[[:space:]]*$/d')" + local_script="$(printf "%s" "$local_script" | sed -e 's/^ *//' -e 's/^#.*$//' -e 's/ #.*//' -e '/^ *$/d')" # XXX: If we want to see what script we're running, then this is the place to print "$local_script". Or above the previous line. # printf "%s" "$local_script"