Created
October 12, 2013 06:00
-
-
Save H2CO3/6946339 to your computer and use it in GitHub Desktop.
This script appends an automatically generated include guard to a specified header file. Optionally, you can provide a prefix that will be added to the guard macro.
This file contains hidden or 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
#!/bin/bash | |
if [ "$#" = "0" ]; then | |
echo "at least one argument is required" | |
exit 1 | |
fi | |
FILE=$1 | |
GUARD="$2$(printf "%s" $FILE | tr '.' '_' | tr '[[:lower:]]' '[[:upper:]]')" | |
cat <<EOF >> $FILE | |
#ifndef $GUARD | |
#define $GUARD | |
#endif /* $GUARD */ | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment