modalias.prov: use "local" builtin rather than "declare"

While (in this case) their effect is the same,
many more people know that "local" makes variables function-local,
than that "declare" in bash does the same. I didn't know.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Denys Vlasenko 2023-05-05 17:40:03 +02:00
parent 510e0c8261
commit 653ec7d086

View File

@ -34,7 +34,7 @@ command -v sed >/dev/null || exit 1
command -v sort >/dev/null || exit 1 command -v sort >/dev/null || exit 1
print_modaliases() { print_modaliases() {
declare class=$1 variants=$2 pos=$3 local class="$1" variants="$2" pos="$3"
if [ -n "$variants" ]; then if [ -n "$variants" ]; then
echo "${class:0:pos}[$variants]${class:pos+1}" echo "${class:0:pos}[$variants]${class:pos+1}"
else else
@ -43,7 +43,7 @@ print_modaliases() {
} }
combine_modaliases() { combine_modaliases() {
declare tag class variants="" pos="" n local tag class variants="" pos="" n
# Due to set -e, we can exit with exitcode 1 on read EOF # Due to set -e, we can exit with exitcode 1 on read EOF
# and this makes our caller think we failed. "|| return 0" prevents this: # and this makes our caller think we failed. "|| return 0" prevents this: