2020: Tentative C & Bash frameworks (common functions)

This commit is contained in:
2022-12-03 14:42:37 +01:00
parent c7553e7849
commit 36f763830f
7 changed files with 121 additions and 66 deletions

View File

@@ -14,17 +14,18 @@
# shellcheck disable=2034
export cmdname=${0##*/}
export debug=0
export part=1
export res=""
export res
shopt -s extglob
set -o noglob
usage() {
printf "usage: %s [-d DEBUG] [-p PART]\n" "$cmdname"
exit 1
}
checkargs() {
local part
while getopts p:d: todo; do
case "$todo" in
d)
@@ -45,7 +46,6 @@ checkargs() {
;;
*)
usage
exit 1
;;
esac
done
@@ -53,14 +53,15 @@ checkargs() {
shift $((OPTIND - 1))
(( $# > 1 )) && usage
return "$part"
}
main() {
local -i part
checkargs "$@"
parse
if ((part == 1)); then
part1
else
part2
fi
part=$?
parse "$part"
solve "$part"
printf "%s: res=%s\n" "$cmdname" "$res"
}