From 1a69f50dc627f6fc5860f871edec357cc0a187e6 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Fri, 24 Jul 2020 08:44:03 +0200 Subject: [PATCH] base-files: fix rc.common help alignment This commit introduces a new function `extra_command` to better format the help text without having to calculate the indentation in every startup script that wants to add a new command. So far it looks weird and is not formatted correctly on some startup scripts. After using the new `extra_command` wrapper the alignement looks correctly. And if the indentation is not sufficient in the future, this can be changed in the function extra_command at a central location. Signed-off-by: Florian Eckert --- package/base-files/Makefile | 2 +- package/base-files/files/etc/rc.common | 38 ++++++++++++++++---------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 84b2f2d5ec..c139ea313b 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=233 +PKG_RELEASE:=234 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index 7c11544405..d3d91ef250 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -62,20 +62,24 @@ depends() { return 0 } +EXTRA_HELP="" +EXTRA_COMMANDS="boot shutdown depends" +extra_command() { + local cmd="$1" + local help="$2" + + local extra="$(printf "%-16s%s" "${cmd}" "${help}")" + EXTRA_HELP="${EXTRA_HELP}\t${extra}\n" + EXTRA_COMMANDS="${EXTRA_COMMANDS} ${cmd}" +} + help() { cat <