From 40cb7cf8d6e31cf768a946e3248618256c021fb6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 4 Oct 2021 18:58:20 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Add=20'opt=5Ffind'=20to=20find?= =?UTF-8?q?=20matching=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/bin/opt_find | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 buildroot/bin/opt_find diff --git a/buildroot/bin/opt_find b/buildroot/bin/opt_find new file mode 100755 index 0000000000..a7c8fd9d71 --- /dev/null +++ b/buildroot/bin/opt_find @@ -0,0 +1,33 @@ +#!/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