mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-29 23:07:42 +00:00
37 lines
961 B
Bash
Executable File
37 lines
961 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# exit on first failure
|
|
set -e
|
|
|
|
# Get SED_CMD, SED_I, and the BSDSED flag
|
|
. $(dirname $0)/opt_sed
|
|
|
|
for opt in "$@" ; do
|
|
DID=0 ; FOUND=0
|
|
for FN in Marlin/Configuration.h Marlin/Configuration_adv.h; do
|
|
if [[ $BSDSED ]]; then
|
|
# BSD sed version (macOS)
|
|
"${SED_CMD}" "${SED_I[@]}" \
|
|
"/^[[:space:]]*#define[[:space:]]+${opt}\b/{
|
|
s/^[[:space:]]*\(#define[[:space:]]+${opt}\b.*\)/\/\/\1/
|
|
h
|
|
\$b end
|
|
}
|
|
\$!b
|
|
:end
|
|
x
|
|
/./{ x; q0; }
|
|
x
|
|
q1" \
|
|
$FN && DID=1
|
|
else
|
|
# GNU sed version
|
|
"${SED_CMD}" "${SED_I[@]}" \
|
|
"/^\(\s*\)\(#define\s\+${opt}\b\s\?\)\(\s\s\)\?/{s//\1\/\/\2/;h};\${x;/./{x;q0};x;q1}" \
|
|
$FN && DID=1
|
|
fi
|
|
((DID||FOUND)) || { grep -E "^\s*\/\/#define\s+${opt}\b" $FN >/dev/null && FOUND=1 ; }
|
|
done
|
|
((DID||FOUND)) || (echo "ERROR: $(basename $0) Can't find ${opt}" >&2 && exit 9)
|
|
done
|