test_cmd_stdin: extract mdat offset automatically (#2681)
Use `grep` to find the first instance of 'mdat'. Clear any `GREP_OPTIONS` and
set `LC_ALL=C` for consistency across platforms.
diff --git a/tests/test_cmd_stdin.sh b/tests/test_cmd_stdin.sh
index cfd00f2..19c35a2 100755
--- a/tests/test_cmd_stdin.sh
+++ b/tests/test_cmd_stdin.sh
@@ -35,11 +35,8 @@
STRIP_HEADER="$2"
if ${STRIP_HEADER}; then
- # The following does not work on all platforms:
- # grep --text mdat "${FILE}"
- # awk -b -v RS='mdat' '{print length($0); exit}' "${FILE}"
- # Hence the hardcoded variable below.
- MDAT_OFFSET=1061
+ MDAT_OFFSET=$(GREP_OPTIONS="" LC_ALL=C \
+ grep -b -m 1 -o --text mdat "${FILE}" | cut -d: -f 1)
dd if="${FILE}" of="${FILE}.strip" bs=1 skip="${MDAT_OFFSET}"
mv "${FILE}.strip" "${FILE}"
fi