diff --git a/script/build/command/options b/include/option.sh similarity index 54% rename from script/build/command/options rename to include/option.sh index e25daeea..1f4f290f 100755 --- a/script/build/command/options +++ b/include/option.sh @@ -1,30 +1,18 @@ -#!/usr/bin/env sh # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2023 Leah Rowe -. "include/err.sh" - -items=1 - -main() -{ - [ $# -gt 0 ] || \ - err "No argument given" - listitems "${1}" || err "No items present under: ${1}" -} - listitems() { - [ -d "${1}" ] || \ - err "Directory not does exist: ${1}" + rval=1 + [ ! -d "${1}" ] && \ + printf "listitems: directory '%s' doesn't exist" "${1}" && \ + return 1 for x in "${1}/"*; do # -e used because this is for files *or* directories [ -e "${x}" ] || continue [ "${x##*/}" = "build.list" ] && continue printf "%s\n" "${x##*/}" 2>/dev/null - items=0 + rval=0 done - return ${items} + return ${rval} } - -main $@ diff --git a/lbmk b/lbmk index eac6afca..395cd130 100755 --- a/lbmk +++ b/lbmk @@ -10,6 +10,7 @@ set -u -e . "include/err.sh" . "include/export.sh" +. "include/option.sh" read projectname < projectname linkpath="${0}" @@ -45,7 +46,7 @@ initialise_command() fail "running this command as root is not permitted" [ "${mode}" = "help" ] && usage ${0} && lbmk_exit 0 - [ "${mode}" = "list" ] && ./build command options "${buildpath}" && \ + [ "${mode}" = "list" ] && listitems "${buildpath}" && \ lbmk_exit 0 [ $# -lt 2 ] && usage ${0} && lbmk_exit 1 @@ -78,7 +79,7 @@ install_packages() execute_command() { if [ "${option}" = "list" ]; then - ./build command options "${buildpath}/${mode}" || \ + listitems "${buildpath}/${mode}" || \ fail "execute_command: cannot list command options" lbmk_exit 0 fi @@ -95,7 +96,7 @@ usage() USAGE: ${progname}