Merge branch 'develop'
[archipelago] / arch-scripts / grep_xseg.sh
diff --git a/arch-scripts/grep_xseg.sh b/arch-scripts/grep_xseg.sh
new file mode 100755 (executable)
index 0000000..f7d108d
--- /dev/null
@@ -0,0 +1,38 @@
+#! /bin/bash
+
+###################
+# Initializations #
+###################
+
+set -e #exit on error
+
+# Find script location
+ARCH_SCRIPTS=$(dirname "$(readlink /proc/$$/fd/255)")
+
+#Include basic functions
+source $ARCH_SCRIPTS/init.sh
+
+SED_XSEG=$(echo "${XSEG}/" | sed 's/\//\\\//g')
+INCLUDE="--include=*.c --include=*.h"
+
+#############
+# Arguments #
+#############
+
+if [[ -z $1 ]]; then
+       red_echo "No parameters given."
+       exit 1
+elif [[ $1 = "-m" ]]; then
+       INCLUDE="--include=Makefile --include=*.mk --include=envsetup"
+       shift
+fi
+
+#############
+# Grep XSEG #
+#############
+
+grep -RIni --color=always ${INCLUDE} \
+       --exclude-dir=python \
+       -e $1 ${XSEG} | \
+       sed 's/'$SED_XSEG'//'
+