From 5683c5027004a11b603318d13f57e7895e20464d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 7 May 2023 17:52:19 +0200 Subject: [PATCH] modalias.prov: use standard "match any char not in set" glob pattern, and sed -E option [^set] is not correct in glob (it's regexp construct). [!set] is. sed: -n is not necessary. -e too. manpage recommends using -E instead of -r. Signed-off-by: Denys Vlasenko --- modalias.prov | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modalias.prov b/modalias.prov index 525e1df..2af9239 100755 --- a/modalias.prov +++ b/modalias.prov @@ -109,12 +109,14 @@ for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@"; do # delete possible extra lines because some modules have *two* version tags. *cough*b44*cough* modver=${modver%%$'\n'*} # using $'' bashism, avoid running "head -n1" process # replace any strange chars with underscores. - modver=${modver//[^0-9a-zA-Z._]/_} + # [!...] is glob's "match any char not in set" pattern + # (although bash supports [^...] too, it is not standard) + modver=${modver//[!0-9a-zA-Z._]/_} # only add version tag if it indeed has a version [ -z "$modver" ] || modver=" = $modver" /sbin/modinfo -F alias "$module" \ - | sed -nre "s,[^][0-9a-zA-Z._:*?/-],_,g; s,(.+),modalias(\\1)$modver,p" + | sed -E "s,[^][0-9a-zA-Z._:*?/-],_,g; s,(.+),modalias(\\1)$modver," # Below: combining code can only possibly combine lines of equal length. # Prepend line lengths before sort, so that same-length lines end up next