From 7fa2dce9e589d89a56f0d1fd7f1518b2e65343f8 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Fri, 28 Feb 2025 09:28:26 +0100 Subject: [PATCH] Simplify boolean flag handling --- mkproj.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mkproj.sh b/mkproj.sh index 9fdf929..a12f36c 100644 --- a/mkproj.sh +++ b/mkproj.sh @@ -2,12 +2,12 @@ config=$HOME/.config/mkprojrc source $config -default=0 +default=false mainfile=main.cpp -gitfav=0 -library=0 -simple=0 -usegitroot=0 +gitfav=false +library=false +simple=false +usegitroot=false usage() { echo "usage: $progname [-f|-l|-n|-s] [[-d] -g |-G] [-t ] PROJECTNAME" >&2 @@ -34,28 +34,28 @@ while getopts :dfGg:lnst:v opt do case $opt in d) - default=1 + default=true ;; f) mainfile=filter.cpp ;; G) - gitfav=1 + gitfav=true ;; g) gitroot=$OPTARG - usegitroot=1 + usegitroot=true ;; l) - library=1 + library=true ;; n) mainfile=main.cpp - library=0 - simple=0 + library=false + simple=false ;; s) - simple=1 + simple=true ;; t) tplroot=$OPTARG @@ -83,7 +83,7 @@ shift $(( OPTIND - 1 )) proj=${1//[- ]/_} # replace all spaces and dashes with underscores -if [ $default = 1 ] +if $default then check_gitroot if grep -q gitroot $config @@ -94,7 +94,7 @@ then fi fi -if [ $gitfav = 1 ] || [ $usegitroot = 1 ] +if $gitfav || $usegitroot then check_gitroot git clone "$gitroot/$proj.git" || die "not an existing repo: $proj" @@ -102,7 +102,7 @@ else mkdir -p "$proj" fi -if [ $simple = 1 ] +if $simple then cp $tplroot/Makefile.simple $proj/Makefile cp $tplroot/main.simple.cpp $proj/$proj.cpp @@ -115,7 +115,7 @@ else sed -e "s/{PROJECT}/$proj/" -e "s/{PROJ}/$uproj/" $tplroot/version.hpp > $proj/src/version.hpp sed -e "s/{PROJECT}/$proj/" $tplroot/version.cpp > $proj/src/version.cpp - if [ $library = 1 ] + if $library then mkdir -p $proj/man/man3 sed -e "s/{PROJECT}/$proj/" $tplroot/lib.3 > $proj/man/man3/$proj.3