Skip to content

Commit 5d2d1ae

Browse files
jzerny-guyon
authored andcommitted
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.
1 parent f5af733 commit 5d2d1ae

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

tests/test_cmd_stdin.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@ strip_header_if() {
3535
STRIP_HEADER="$2"
3636

3737
if ${STRIP_HEADER}; then
38-
# The following does not work on all platforms:
39-
# grep --text mdat "${FILE}"
40-
# awk -b -v RS='mdat' '{print length($0); exit}' "${FILE}"
41-
# Hence the hardcoded variable below.
42-
MDAT_OFFSET=1061
38+
MDAT_OFFSET=$(GREP_OPTIONS="" LC_ALL=C \
39+
grep -b -m 1 -o --text mdat "${FILE}" | cut -d: -f 1)
4340
dd if="${FILE}" of="${FILE}.strip" bs=1 skip="${MDAT_OFFSET}"
4441
mv "${FILE}.strip" "${FILE}"
4542
fi

0 commit comments

Comments
 (0)