diff --git a/scripts/inject-clippy.sh b/scripts/inject-clippy.sh index 58a87ea..a31205d 100755 --- a/scripts/inject-clippy.sh +++ b/scripts/inject-clippy.sh @@ -13,16 +13,18 @@ mv -v $ORIGINAL_LOCATION $NEW_LOCATION sed "s|REPLACE_ME|$NEW_LOCATION|g" > $ORIGINAL_LOCATION << 'EOF' #!/bin/bash -ORIGINAL_PARAMS=("$@") - -# FIXME: "build" doesn't have to *always* be the first arg -if [[ $1 == "build" ]]; then - set -x - set -- "clippy" "${@:2}" - REPLACE_ME "$@" --message-format=json >> /builddir/clippy-output.txt -fi - -REPLACE_ME "${ORIGINAL_PARAMS[@]}" +# look for "build" in command-line args +for arg in "$@"; do + if [[ "$arg" == "build" ]]; then + # found! --> execute the command with "build" substituted by "clippy" + set -x + REPLACE_ME "${@/build/clippy}" --message-format=json >> /builddir/clippy-output.txt + break + fi +done + +# execute the original command in any case +exec REPLACE_ME "$@" EOF chmod +x $ORIGINAL_LOCATION