update: make it pass shellcheck
Without that fix, running 'shellcheck -x build' produces the following errors/warnings: In update line 81: case "${option}" in ^-- SC1009 (info): The mentioned syntax error was in this case expression. In update line 82: list) ^-- SC1073 (error): Couldn't parse this case item. Fix to allow more checks. In update line 92: all) ^-- SC1072 (error): Fix any mentioned problems and try again. ^-- SC1074 (error): Did you forget the ;; after the previous case item? After fixing these and rerunning 'shellcheck -x build', we then have the following errors/warnings: In update line 23: [ "x${DEBUG+set}" = 'xset' ] && set -v ^-------------^ SC2268 (style): Avoid x-prefix in comparisons as it no longer serves a purpose. In update line 32: ls -d resources/packages/*/update/ | \ ^-- SC2012 (info): Use find instead of ls to better handle non-alphanumeric filenames. In update line 40: ls -d resources/packages/"${package}"/update/* | \ ^-- SC2012 (info): Use find instead of ls to better handle non-alphanumeric filenames. In update line 95: resources/packages/"${package}"/update/"${option}" $@ ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements. In update line 102: "${pkg_dir}"/update/"${option}" $@ ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements. so we fix them as well. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Acked-by: Adrien 'neox' Bourmault <neox@gnu.org>
This commit is contained in:
parent
68cb3ac110
commit
7bf153a207
|
@ -44,6 +44,7 @@ run_shellcheck \
|
||||||
build \
|
build \
|
||||||
download \
|
download \
|
||||||
modify \
|
modify \
|
||||||
|
update \
|
||||||
resources/packages/descriptors/distclean \
|
resources/packages/descriptors/distclean \
|
||||||
resources/packages/flashrom/distclean \
|
resources/packages/flashrom/distclean \
|
||||||
resources/packages/grub/distclean \
|
resources/packages/grub/distclean \
|
||||||
|
|
23
update
23
update
|
@ -20,7 +20,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
[ "${DEBUG+set}" = 'set' ] && set -v
|
||||||
set -u -e
|
set -u -e
|
||||||
|
|
||||||
projectname="$(cat projectname)"
|
projectname="$(cat projectname)"
|
||||||
|
@ -28,17 +28,26 @@ projectname="$(cat projectname)"
|
||||||
|
|
||||||
. resources/scripts/misc/sysexits.sh
|
. resources/scripts/misc/sysexits.sh
|
||||||
|
|
||||||
|
list_update_paths() {
|
||||||
|
find resources/packages \
|
||||||
|
-mindepth 2 -maxdepth 2 \
|
||||||
|
-type d \
|
||||||
|
-name "update" \
|
||||||
|
-printf "%P\n"
|
||||||
|
}
|
||||||
|
|
||||||
list_packages() {
|
list_packages() {
|
||||||
ls -d resources/packages/*/update/ | \
|
list_update_paths | \
|
||||||
sed 's#resources/packages/##' | \
|
|
||||||
sed 's#/.*##'
|
sed 's#/.*##'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Takes exactly one package as parameter
|
# Takes exactly one package as parameter
|
||||||
listoptions() {
|
listoptions() {
|
||||||
package="${1}"
|
package="${1}"
|
||||||
ls -d resources/packages/"${package}"/update/* | \
|
find resources/packages/"${package}/update/" \
|
||||||
sed 's#resources/packages/'"${package}"'/update/##'
|
-mindepth 1 -maxdepth 1 \
|
||||||
|
-type f \
|
||||||
|
-printf "%P\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
|
@ -89,8 +98,10 @@ if [ $# -gt 1 ]; then
|
||||||
"${package}"
|
"${package}"
|
||||||
listoptions "${package}"
|
listoptions "${package}"
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
all)
|
all)
|
||||||
for option in $(listoptions "${package}"); do
|
for option in $(listoptions "${package}"); do
|
||||||
|
# shellcheck disable=SC2068
|
||||||
resources/packages/"${package}"/update/"${option}" $@
|
resources/packages/"${package}"/update/"${option}" $@
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
@ -98,6 +109,7 @@ if [ $# -gt 1 ]; then
|
||||||
if [ -d resources/packages/"${package}"/update ]; then
|
if [ -d resources/packages/"${package}"/update ]; then
|
||||||
pkg_dir=resources/packages/"${package}"
|
pkg_dir=resources/packages/"${package}"
|
||||||
if [ -f "${pkg_dir}"/update/"${option}" ]; then
|
if [ -f "${pkg_dir}"/update/"${option}" ]; then
|
||||||
|
# shellcheck disable=SC2068
|
||||||
"${pkg_dir}"/update/"${option}" $@
|
"${pkg_dir}"/update/"${option}" $@
|
||||||
else
|
else
|
||||||
help
|
help
|
||||||
|
@ -111,6 +123,7 @@ if [ $# -gt 1 ]; then
|
||||||
"Invalid package '${package}'." \
|
"Invalid package '${package}'." \
|
||||||
" See './update --help'."
|
" See './update --help'."
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
help
|
help
|
||||||
|
|
Loading…
Reference in New Issue