From e12eba95bb42a00f4453e1efad1134d8283a7b2b Mon Sep 17 00:00:00 2001 From: th33xitus Date: Mon, 15 Aug 2022 13:18:18 +0200 Subject: [PATCH] style: improve function description Signed-off-by: Dominik Willner --- scripts/utilities.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/utilities.sh b/scripts/utilities.sh index 2940e90..88d83e3 100644 --- a/scripts/utilities.sh +++ b/scripts/utilities.sh @@ -670,13 +670,21 @@ function set_hostname() { #============ INSTANCE MANAGEMENT ===============# #================================================# -### this function takes in the full path of a systemd service file and returns -### either the instance index or the custom name -### input: /etc/systemd/system/klipper-name.service -### returns: name +### +# takes in a systemd service files full path and +# returns the sub-string with the instance name +# +# @param {string}: service file absolute path +# (e.g. '/etc/systemd/system/klipper-.service') +# +# => return sub-string containing only the part of the full string +# function get_instance_name() { - local instance=${1} name + local instance=${1} + local name + name=$(echo "${instance}" | rev | cut -d"/" -f1 | cut -d"." -f2 | cut -d"-" -f1 | rev) + echo "${name}" }