From 5c2342f6c0aaa0603b5d905c672acc14537a8775 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Thu, 5 May 2016 12:53:06 +0200 Subject: [PATCH] diff_man: detect extented regex for sed --- scripts/diff_man_help.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/diff_man_help.sh b/scripts/diff_man_help.sh index dda4779..047c60d 100644 --- a/scripts/diff_man_help.sh +++ b/scripts/diff_man_help.sh @@ -12,21 +12,29 @@ TMPDIR=$(mktemp -d svtplay-man-test-XXXXXX) } trap 'rm -rf "$TMPDIR"' EXIT TERM +if echo "" | sed -r "" > /dev/null 2>&1 ; then + extended_regexp="-r" +elif echo "" | sed -E "" > /dev/null 2>&1 ; then + extended_regexp="-E" +else + echo "Cant find extented regex" +fi + # FIXME: *Currently* we don't have any =head3 that doesn't # document an option. This is thus fragile to changes. -sed -nre 's/^=head3 //p' svtplay-dl.pod > $TMPDIR/options.man +sed $extended_regexp -ne 's/^=head3 //p' svtplay-dl.pod > $TMPDIR/options.man ./svtplay-dl --help | grep '^ *-' > $TMPDIR/options.help # --help specific filtering -sed -i -re 's/ .*//' $TMPDIR/options.help -sed -i -re 's/ excl.*//' $TMPDIR/options.help -sed -i -re 's/^ *//' $TMPDIR/options.help -sed -i -re 's/OUTPUT/filename/g' $TMPDIR/options.help +sed -i $extended_regexp -e 's/ .*//' $TMPDIR/options.help +sed -i $extended_regexp -e 's/ excl.*//' $TMPDIR/options.help +sed -i $extended_regexp -e 's/^ *//' $TMPDIR/options.help +sed -i $extended_regexp -e 's/OUTPUT/filename/g' $TMPDIR/options.help for file in $TMPDIR/options.*; do - sed -i -re 's/, / /' $file - sed -i -re 's/ / /' $file + sed -i $extended_regexp -e 's/, / /' $file + sed -i $extended_regexp -e 's/ / /' $file # Normalize order of --help -h vs -h --help # "--help -h" => "-h --help"