From fc73efe0cae03f37ffe89a4511b7f97a16152e7e Mon Sep 17 00:00:00 2001 From: zenobit Date: Mon, 27 Mar 2023 02:38:27 +0200 Subject: [PATCH] add function sort_functions --- dh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dh b/dh index c039acd..8e663c5 100755 --- a/dh +++ b/dh @@ -379,6 +379,21 @@ function add_distro() { meld "${TMP_DIR}/${NAME}.tmp $DH_CONFIG_DIR/quickget" } +function sort_functions() { + # Get the name of the script from the command line argument + script_name=$1 + # Get a list of all the function names in the script + function_names=$(grep -oP '^[[:space:]]*function \K\w+' "$script_name") + # Sort the function names alphabetically + sorted_function_names=$(echo "$function_names" | sort) + # Loop through the sorted function names and print the function definitions + for function_name in $sorted_function_names + do + # Print the function definition to stdout + grep -A $(wc -l < "$script_name") -w "function $function_name" "$script_name" + done +} + function localization() { # načtení souboru s lokalizací . gettext.sh