Skip to content

Commit

Permalink
Fix build script options (NOAA-EMC#801)
Browse files Browse the repository at this point in the history
There was an issue where if build_all.sh was called with only options that are not used by partial_build.sh, partial_build.sh would see those options because $@ was not overwritten. The script have been updated to consume those options so they are no longer present if $@ isn't overwritten in the new script call.

Also fixed the getopts statement in partial_build.sh so we handle errors instead of bash (bash would report the wrong script if the script is sourced)

Fixes NOAA-EMC#800
  • Loading branch information
WalterKolczynski-NOAA authored May 20, 2022
1 parent fa12db2 commit 58728fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions sorc/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ while getopts ":a:c:hv" option; do
# s) _build_ufs_opt+="-s ${OPTARG} ";;
v) _verbose_opt="-v";;
\?)
echo "Unrecognized option: ${option}"
echo "[$BASH_SOURCE]: Unrecognized option: ${option}"
usage
;;
:)
echo "${option} requires an argument"
echo "[$BASH_SOURCE]: ${option} requires an argument"
usage
;;
esac
done

shift $((OPTIND-1))

build_dir=$(pwd)
logs_dir=$build_dir/logs
if [ ! -d $logs_dir ]; then
Expand Down
8 changes: 5 additions & 3 deletions sorc/partial_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ verbose=false
config_file="gfs_build.cfg"
# Reset option counter for when this script is sourced
OPTIND=1
while getopts "c:hs:v" option; do
while getopts ":c:hs:v" option; do
case "${option}" in
c) config_file="${OPTARG}";;
h) usage;;
Expand All @@ -162,16 +162,18 @@ while getopts "c:hs:v" option; do
parse_argv+=( "--verbose" )
;;
\?)
echo "Unrecognized option: ${option}"
echo "[$BASH_SOURCE]: Unrecognized option: ${option}"
usage
;;
:)
echo "${option} requires an argument"
echo "[$BASH_SOURCE]: ${option} requires an argument"
usage
;;
esac
done

shift $((OPTIND-1))

parse_argv+=( "config=$config_file" )

#
Expand Down

0 comments on commit 58728fb

Please sign in to comment.