Skip to content

Commit

Permalink
linux-info.eclass: get_localversion, do not call 'ls'
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mgorny committed Jul 9, 2018
1 parent 7fd74e8 commit 64d475c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion eclass/linux-info.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 64d475c

Please sign in to comment.