From b14d9ed658d7e0cf41e233d86b86eb6f77d8733b Mon Sep 17 00:00:00 2001 From: illiliti Date: Mon, 9 Mar 2020 16:22:21 +0300 Subject: [PATCH] switch to for loop --- tinyramfs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/tinyramfs b/tinyramfs index a9582d0..9408d93 100755 --- a/tinyramfs +++ b/tinyramfs @@ -80,25 +80,13 @@ parse_args() { } prepare_environment() { - if [ -f "$_config" ]; then - . "$_config" - elif [ -f /etc/tinyramfs/config ]; then - . /etc/tinyramfs/config - elif [ -f ./config ]; then - . ./config - else - msg panic "failed to source config" - fi + for _file in $_config /etc/tinyramfs/config ./config; do + [ -f "$_file" ] && . "$_file" && break + done || msg panic "failed to source config" - if [ -d "$_filesdir" ]; then - filesdir="$_filesdir" - elif [ -d /usr/share/tinyramfs ]; then - filesdir="/usr/share/tinyramfs" - elif [ -d ./usr/share/tinyramfs ]; then - filesdir="./usr/share/tinyramfs" - else - msg panic "failed to find required files" - fi + for _dir in $_filesdir /usr/share/tinyramfs ./usr/share/tinyramfs; do + [ -d "$_dir" ] && filesdir="$_dir" && break + done || msg panic "failed to locate required files" kernel="${_kernel:-${kernel:-$(uname -r)}}" moddir="${_moddir:-${moddir:-/lib/modules}}"