autodate.sh: Allow alternative name for sed
PATCH 1/2 autodate.sh: Allow alternative name for sed
It turns out that native sed on FreeBSD doesn't work well in autodate.sh. GNU compatible sed can be specified by make/shell variable SED.
Signed-off-by Akira Yokosawa <[email protected]>
--- utilities/autodate.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
utilities/autodate.sh +6 -5
@@ -28,6 +28,7 @@ qqzbg="false" fn="autodate.tex" : ${DATE:=date} +: ${SED:=sed} # check if we have tcolorbox tcolorbox_sty=`kpsewhich tcolorbox.sty`
@@ -77,24 +78,24 @@ else esac case "$description" in Edition[.-][0-9]*) - ednum="`echo $description | sed -e 's/^Edition[.-]\([0-9]*\).*$/\1/'`" + ednum="`echo $description | $SED -e 's/^Edition[.-]\([0-9]*\).*$/\1/'`" release=`env printf '\\Ordinalstringnum{%s} %s' $ednum "$release"` ;; esac case "$description" in *-rc[0-9]*) - rc="`echo $description | sed -e 's/^.*-rc\(.*\)$/\1/'`" + rc="`echo $description | $SED -e 's/^.*-rc\(.*\)$/\1/'`" release="$release, Release Candidate $rc" ;; esac ;; *) release=`env printf 'Tag: \\\texttt{%s}' "$description"` - commitid=`echo $description | sed -e 's/.*-\(g.*\)/\1/'` + commitid=`echo $description | $SED -e 's/.*-\(g.*\)/\1/'` ;; esac else - description=`git log --max-count=1 | head -n 1 | sed -e 's/^commit \([0-9a-f]\{12\}\).*$/g\1/'` + description=`git log --max-count=1 | head -n 1 | $SED -e 's/^commit \([0-9a-f]\{12\}\).*$/g\1/'` release=`env printf 'Commit: \\\texttt{%s} (shallow clone)' "$description"` commitid="$description" fi
@@ -125,7 +126,7 @@ env printf '\\newcommand{\\commitid}{%s}\n' $commitid$modified >> $fn env printf '\\IfQqzBg{}{\\setboolean{qqzbg}{%s}}\n' $qqzbg >> $fn # command for newer tcolorbox (4.40 or later) to have backward-compatible skips -tcbversion=`grep ProvidesPackage $tcolorbox_sty | sed -e 's/.*version \([0-9]\+\.[0-9]\+\).*/\1/g'` +tcbversion=`grep ProvidesPackage $tcolorbox_sty | $SED -e 's/.*version \([0-9]\+\.[0-9]\+\).*/\1/g'` tcbold=4.39 env printf '%% tcolorbox version: %s\n' $tcbversion >> $fn if [ $(echo $tcbversion $tcbold | awk '{if ($1 > $2) print 1;}') ] ;
base-commit: 71129aa0193b4cd29bc59ac6f5ee22982f20901b
Signature · 1 line
2.25.1
PATCH 2/2 precheck.sh: Test sed against repeat patterns \+ and \?
It turns out that missing features in FreeBSD sed are repeat patterns of "\? and \+.
Test them in precheck.sh instead of running extractqqz.sh.
Update FAQ-BUILD.txt accordingly.
Signed-off-by Akira Yokosawa <[email protected]>
--- FAQ-BUILD.txt | 2 +- utilities/precheck.sh | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-)
FAQ-BUILD.txt +1 -1
@@ -342,7 +342,7 @@ - GNU make - /usr/bin/env - date: format options of either GNU or BSD flavor - - sed: multi-line edit + - sed: repeat patterns \? and \+ - grep: -z option (optional) Among requirements above, features of date and sed are checked
utilities/precheck.sh +6 -12
@@ -15,19 +15,15 @@ LC_TIME=C fatal="" -tmp_file_dir=$(mktemp -d) -tmp_file=$tmp_file_dir/precheck - -# test sed (multi-line edit) +# test sed (repeat pattern \? and \+) sed_result="" -sh utilities/extractqqz.sh < count/count.tex > $tmp_file 2> /dev/null -if grep -q -F "QuickQ{}" $tmp_file ; then +sed_out=`echo aaabbc | $SED -e 's/[ab]\+c\?//'` +if [ "$sed_out" = "" ] ; then sed_result="OK" else sed_result="NG" fatal="sed $fatal" fi -rm -f $tmp_file # test date (format conversion) date_result=""
@@ -50,8 +46,6 @@ else fatal="date-format $fatal" fi -rm -rf $tmp_file_dir - if [ "$fatal" = "" -a "$VERBOSE" = "" ] ; then exit 0 fi
@@ -63,9 +57,9 @@ echo "===========================================" if [ "$sed_result" != "OK" -o "$VERBOSE" != "" ] ; then echo - echo "------------------------------------------" - echo " testing sed (multi-line edit) " - echo "------------------------------------------" + echo '------------------------------------------' + echo ' testing sed (repeat patterns \? and \+) ' + echo '------------------------------------------' if [ "$sed_result" = "OK" ] ; then echo "OK." else
Signature · 1 line
2.25.1
Paul E. McKenney
AppliedQuoted 5 lines · Akira Yokosawa
It turns out that native sed on FreeBSD doesn't work well in
autodate.sh. GNU compatible sed can be specified by make/shell variable SED.Signed-off-by Akira Yokosawa <[email protected]>
Queued and pushed both, thank you!
Thanx, Paul
Quoted 59 lines
--- utilities/autodate.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)utilities/autodate.sh +6
-5@@ -28,6 +28,7 @@ qqzbg="false" fn="autodate.tex" : ${DATE:=date} +: ${SED:=sed} # check if we have tcolorbox tcolorbox_sty=`kpsewhich tcolorbox.sty`@@ -77,24 +78,24 @@ else esac case "$description" in Edition[.-][0-9]*) - ednum="`echo $description | sed -e 's/^Edition[.-]\([0-9]*\).*$/\1/'`" + ednum="`echo $description | $SED -e 's/^Edition[.-]\([0-9]*\).*$/\1/'`" release=`env printf '\\Ordinalstringnum{%s} %s' $ednum "$release"` ;; esac case "$description" in *-rc[0-9]*) - rc="`echo $description | sed -e 's/^.*-rc\(.*\)$/\1/'`" + rc="`echo $description | $SED -e 's/^.*-rc\(.*\)$/\1/'`" release="$release, Release Candidate $rc" ;; esac ;; *) release=`env printf 'Tag: \\\texttt{%s}' "$description"` - commitid=`echo $description | sed -e 's/.*-\(g.*\)/\1/'` + commitid=`echo $description | $SED -e 's/.*-\(g.*\)/\1/'` ;; esac else - description=`git log --max-count=1 | head -n 1 | sed -e 's/^commit \([0-9a-f]\{12\}\).*$/g\1/'` + description=`git log --max-count=1 | head -n 1 | $SED -e 's/^commit \([0-9a-f]\{12\}\).*$/g\1/'` release=`env printf 'Commit: \\\texttt{%s} (shallow clone)' "$description"` commitid="$description" fi@@ -125,7 +126,7 @@ env printf '\\newcommand{\\commitid}{%s}\n' $commitid$modified >> $fn env printf '\\IfQqzBg{}{\\setboolean{qqzbg}{%s}}\n' $qqzbg >> $fn # command for newer tcolorbox (4.40 or later) to have backward-compatible skips -tcbversion=`grep ProvidesPackage $tcolorbox_sty | sed -e 's/.*version \([0-9]\+\.[0-9]\+\).*/\1/g'` +tcbversion=`grep ProvidesPackage $tcolorbox_sty | $SED -e 's/.*version \([0-9]\+\.[0-9]\+\).*/\1/g'` tcbold=4.39 env printf '%% tcolorbox version: %s\n' $tcbversion >> $fn if [ $(echo $tcbversion $tcbold | awk '{if ($1 > $2) print 1;}') ] ;base-commit:
71129aa0193b4cd29bc59ac6f5ee22982f20901bSignature · 1 line
2.25.1