mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-21 23:38:49 -05:00
Refactor lint_source to work with earlier versions of Bash
Negative subscripts to indexed arrays are not supported before 4.2. However, since substring expansion works on arrays, we can specify an offset of -1 to be taken relative to one greater than the maximum index of the specified array (see Parameter Expansion section of the bash man page). This works with both Bash 4.1 and 4.2, and 4.1 is already the oldest supported by pacman. Signed-off-by: Aaron Campbell <aaron@monkey.org> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
8fa02036c3
commit
bf0e8e6b43
@ -32,7 +32,7 @@ lint_pkgbuild_functions+=('lint_source')
|
||||
lint_source() {
|
||||
local idx=("${!source[@]}")
|
||||
|
||||
if (( ${#source[*]} > 0 && (idx[-1] + 1) != ${#source[*]} )); then
|
||||
if (( ${#source[*]} > 0 && (${idx[@]: -1} + 1) != ${#source[*]} )); then
|
||||
error "$(gettext "Sparse arrays are not allowed for source")"
|
||||
return 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user