diff options
author | Leah Rowe <leah@libreboot.org> | 2023-05-18 11:24:08 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2023-05-18 11:24:08 +0100 |
commit | 9fb489ac3eaa1782a747e177ad01aacc1ff0cc1e (patch) | |
tree | 239d4a72548f369d08c6d1d6ef7c098457bfb38b | |
parent | f7f3aef17e0a4a210e23829c3f40e34e69f6466f (diff) |
modify: clean up duplicated code
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-x | modify | 21 |
1 files changed, 7 insertions, 14 deletions
@@ -51,10 +51,10 @@ main() case "${option}" in list) printf "Options for mode '%s':\n\n" ${mode} - listoptions "${mode}" + listitems "${modify}/${mode}" ;; all) - for option in $(listoptions "${mode}"); do + for option in $(listitems "${modify}/${mode}"); do "${modify}/${mode}/${option}" $@ done ;; @@ -71,21 +71,13 @@ main() esac } -# Takes exactly one mode as parameter -listoptions() -{ - for option in "${modify}/${1}/"*; do - printf '%s\n' ${option##*/} - done -} - help() { cat <<- EOF USAGE: ./modify <MODE> <OPTION> possible values for 'mode': - $(listmodes) + $(listitems "${modify}") Example: ./modify coreboot configs Example: ./modify coreboot configs x60 @@ -94,10 +86,11 @@ help() EOF } -listmodes() +listitems() { - for mode in "${modify}/"*; do - printf '%s\n' "${mode##*/}" + for x in "${1}/"*; do + [ ! -f "${x}" ] && continue + printf "%s\n" ${x##*/} done } |