You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
871 B
34 lines
871 B
3 years ago
|
#!/usr/bin/env bash
|
||
|
#
|
||
|
# opt_find
|
||
|
# Find one or more Marlin options - Configuration lines starting with #define
|
||
|
#
|
||
|
|
||
|
MYNAME=$(basename $0)
|
||
|
|
||
|
[[ $# == 0 ]] && ONE="-h" || ONE=$1
|
||
|
|
||
|
COMM="(//\\s*)?" ; TYPE=""
|
||
|
case "$ONE" in
|
||
|
-d|--disabled )
|
||
|
shift ; COMM="(//\\s*)" ; TYPE="disabled " ;;
|
||
|
-e|--enabled )
|
||
|
shift ; COMM="" ; TYPE="enabled " ;;
|
||
|
-h|--help )
|
||
|
echo "$MYNAME [-d|--disabled|-e|--enabled] STRING ... Find matching Marlin configuration options."
|
||
|
echo ; shift ;;
|
||
|
-* )
|
||
|
echo "Unknown option $ONE" ; shift ;;
|
||
|
esac
|
||
|
|
||
|
while [[ $# > 0 ]]; do
|
||
|
DID=0
|
||
|
for FN in Configuration Configuration_adv; do
|
||
|
FOUND=$( grep -HEn "^\s*${COMM}#define\s+[A-Z0-9_]*${1}" "Marlin/$FN.h" 2>/dev/null )
|
||
|
[[ -n "$FOUND" ]] && { echo "$FOUND" ; DID=1 ; }
|
||
|
done
|
||
|
((DID)) || { echo "ERROR: ${MYNAME} - No ${TYPE}match for ${1}" ; exit 9; }
|
||
|
shift
|
||
|
echo
|
||
|
done
|