Skip to content

Commit

Permalink
lib/zfsbootmenu-kcl: clean up argument reading
Browse files Browse the repository at this point in the history
  • Loading branch information
ahesford committed Dec 2, 2023
1 parent 07d6e73 commit 0d29988
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions zfsbootmenu/lib/zfsbootmenu-kcl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,17 @@ get_zbm_arg() {
[ -n "${1}" ] || return 1
[ -d "${BASE}/cmdline.d" ] || make_cmdline_dir

local kopt
local kopt kval
for kopt in "$@"; do
if [ -f "${BASE}/cmdline.d/${kopt}" ] ; then
head -1 < "${BASE}/cmdline.d/${kopt}"
[ "${kopt}" = "${1}" ] || zwarn "using deprecated arg '${kopt}' when '${1}' is preferred"
return 0
[ -r "${BASE}/cmdline.d/${kopt}" ] || continue

if [ "${kopt}" != "${1}" ]; then
zwarn "using deprecated arg '${kopt}' when '${1}' is preferred"
fi

read -r kval < "${BASE}/cmdline.d/${kopt}"
echo "${kval}"
return 0
done

return 1
Expand Down

0 comments on commit 0d29988

Please sign in to comment.