Use bash array to perform a safe filename glob instead of calling 'ls'.
Also, use nullglob to cleanly handle no matches instead of silencing
errors.
---
 eclass/linux-info.eclass | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
index 035b722e2d6d..b8c1a524bae8 100644
--- a/eclass/linux-info.eclass
+++ b/eclass/linux-info.eclass
@@ -390,8 +390,13 @@ kernel_is() {
 get_localversion() {
        local lv_list i x
 
+       local shopt_save=$(shopt -p nullglob)
+       shopt -s nullglob
+       local files=( ${1}/localversion* )
+       ${shopt_save}
+
        # ignore files with ~ in it.
-       for i in $(ls ${1}/localversion* 2>/dev/null); do
+       for i in "${files[@]}"; do
                [[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}"
        done
 
-- 
2.16.2


Reply via email to