Make script to silence output unless errors and always recompile

From Tech Wiki
Revision as of 02:07, 29 January 2022 by Adam.birds (talk | contribs) (Created page with "'''Here is the script to silence output when running make unless their are errors, it will also always recompile too:''' <pre> #!/bin/bash # Ensure no targets end with .c ar...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here is the script to silence output when running make unless their are errors, it will also always recompile too:

#!/bin/bash

# Ensure no targets end with .c
args=""
invalid_args=0
for arg; do
    case "$arg" in
        (*.c) arg=${arg%.c}; invalid_args=1;;
    esac
    args="$args $arg"
done
if [ $invalid_args -eq 1 ]; then
    echo "Did you mean 'make$args'?"
    exit 1
fi

# Run make
/usr/bin/make -B -s $*

Copy the above into the below file:

/usr/local/bin/make

Then run:

sudo chmod +x /usr/local/bin/make