aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2020-08-01 15:48:43 +0200
committerThomas Deutschmann <whissi@gentoo.org>2020-08-01 22:35:00 +0200
commitc8624437130d318d93596453d0057f8fdfbe1ed2 (patch)
tree0cebf1236b99fe28daf6c4693b3af9349ccbe881 /gen_funcs.sh
parentgenkernel: Move grep/zgrep check to determine_real_args() (diff)
downloadgenkernel-c8624437130d318d93596453d0057f8fdfbe1ed2.tar.gz
genkernel-c8624437130d318d93596453d0057f8fdfbe1ed2.tar.bz2
genkernel-c8624437130d318d93596453d0057f8fdfbe1ed2.zip
Unify 'confgrep' handling via new get_grep_cmd_for_file() function
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'gen_funcs.sh')
-rwxr-xr-xgen_funcs.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/gen_funcs.sh b/gen_funcs.sh
index b9aa5108..f2f075a7 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -440,6 +440,27 @@ gen_die() {
exit 1
}
+get_grep_cmd_for_file() {
+ [[ ${#} -ne 1 ]] \
+ && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!"
+
+ local config_file=${1}
+
+ local grep_cmd=${GREP_CMD}
+ if isTrue "$(is_gzipped "${config_file}")"
+ then
+ grep_cmd=${ZGREP_CMD}
+ fi
+
+ # zgrep for example is optional
+ if [ -z "${grep_cmd}" ]
+ then
+ gen_die "$(get_useful_function_stack "${FUNCNAME}")No grep implementation found which can process '${config_file}'!"
+ fi
+
+ echo "${grep_cmd}"
+}
+
# @FUNCTION: get_indent
# @USAGE: <level>
# @DESCRIPTION: