Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOA] Process command line args after SBT_OPTS #235

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions sbt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,25 @@ declare -a java_args scalac_args sbt_commands residual_args
# args to jvm/sbt via files or environment variables
declare -a extra_jvm_opts extra_sbt_opts

declare -a verbose_messages

echoerr () { echo >&2 "$@"; }
vlog () { [[ -n "$verbose" ]] && echoerr "$@"; }
die () { echo "Aborting: $*" ; exit 1; }

vlog () {
if [[ -n "$verbose" ]]; then
echoerr "$@"
else
verbose_messages+=("$*")
fi
}
enable_verbose () {
verbose=true
for msg in "${verbose_messages[@]}"; do
echoerr "$msg"
done
}

setTrapExit () {
# save stty and trap exit, to ensure echo is re-enabled if we are interrupted.
SBT_STTY="$(stty -g 2>/dev/null)"
Expand Down Expand Up @@ -369,7 +384,7 @@ process_args () {
while [[ $# -gt 0 ]]; do
case "$1" in
-h|-help) usage; exit 0 ;;
-v) verbose=true && shift ;;
-v) enable_verbose && shift ;;
-d) addSbt "--debug" && shift ;;
-w) addSbt "--warn" && shift ;;
-q) addSbt "--error" && shift ;;
Expand Down Expand Up @@ -416,9 +431,6 @@ process_args () {
done
}

# process the direct command line arguments
process_args "$@"

# skip #-styled comments and blank lines
readConfigFile() {
local end=false
Expand All @@ -428,7 +440,7 @@ readConfigFile() {
done < "$1"
}

# if there are file/environment sbt_opts, process again so we
# if there are file/environment sbt_opts, process so we
# can supply args to this runner
if [[ -r "$sbt_opts_file" ]]; then
vlog "Using sbt options defined in file $sbt_opts_file"
Expand All @@ -442,6 +454,9 @@ fi

[[ -n "${extra_sbt_opts[*]}" ]] && process_args "${extra_sbt_opts[@]}"

# process the direct command line arguments
process_args "$@"

# reset "$@" to the residual args
set -- "${residual_args[@]}"
argumentCount=$#
Expand Down