-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
82 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
#!/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 | ||
# If a single target and not an option | ||
if [[ $# -eq 1 ]] && [[ "$1" != -* ]]; then | ||
|
||
# If no Makefile | ||
if [[ ! -f Makefile && ! -f makefile ]]; then | ||
|
||
# Run make | ||
if [[ -d "$1" ]]; then | ||
echo "$1 is a directory" | ||
exit 1 | ||
else | ||
/usr/bin/make -B -s $* | ||
# If target ends with .c or is a directory | ||
if [[ "$1" == *?.c || -d "$1" ]]; then | ||
|
||
# Don't suppress "Nothing to be done" with --silent | ||
/usr/bin/make "$1" | ||
exit $? | ||
fi | ||
fi | ||
fi | ||
|
||
# Don't echo recipes | ||
/usr/bin/make --always-make --silent "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
#!/bin/bash | ||
#!/bin/bash -l | ||
|
||
# Formatting | ||
bold=$(tput bold) | ||
normal=$(tput sgr0) | ||
# If one command-line argument and not an option | ||
if [[ $# -eq 1 ]] && [[ "$1" != -* ]]; then | ||
|
||
# If run on Python program | ||
if [[ "$1" == "python" || "$1" == *.py ]]; then | ||
echo "Afraid ${bold}valgrind${normal} does not support Python programs!" | ||
exit 1 | ||
# If run on Python program | ||
if [[ "$1" =~ ^(python|python3)$ ]]; then | ||
if ! _sure "Are you sure you want to run \`valgrind\` on \`$1\`? Valgrind does not support Python programs."; then | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# If not run on ./* | ||
if [[ ! "$1" =~ ^./ ]]; then | ||
|
||
# If $1 is in $PATH | ||
if command -v "$1" &> /dev/null; then | ||
|
||
# Discourage user from debugging $1 | ||
if [[ -f "$1" ]]; then | ||
if ! _sure "Are you sure you want to run \`valgrind $1\` and not, e.g., \`valgrind ./$1\`?"; then | ||
exit 1 | ||
fi | ||
else | ||
if ! _sure "Are you sure you want to run \`valgrind\` on \`$1\`, which isn't in your current directory?"; then | ||
exit 1 | ||
fi | ||
fi | ||
fi | ||
fi | ||
fi | ||
|
||
/usr/bin/valgrind "$@" |