Skip to contentSkip to conversation

utilities/autodate.sh: Fix potential hung-up on missing tcolorbox

PATCH Superseded Akira Yokosawa 2 participants 8 messages May 2, 2021 – May 3, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utilities/autodate.sh: Fix potential hung-up on missing tcolorbox

"kpsewhich tcolorbox.sty" can be empty if tcolorbox is not available.

If this is the case, "grep" in grep ProvidePackage | sed ... will wait forever.

Add an empty check in front of "grep" with exit code of 1.

Fixes b2f19231bcc5 ("utilities/autodate.sh: Make newer tcolorbox behave as before")
---
 utilities/autodate.sh | 7 +++++++
 1 file changed, 7 insertions(+)
utilities/autodate.sh +7 -0
index 7bd7cbb8..2b9c1117 100644
@@ -97,6 +97,13 @@ env printf '\\IfQqzBg{}{\\setboolean{qqzbg}{%s}}\n' $qqzbg
 
 # command for newer tcolorbox (4.40 or later) to have backward-compatible skips
 tcolorbox_sty=`kpsewhich tcolorbox.sty`
+
+if [ "$tcolorbox_sty" == "" ]
+then
+	echo "Error: package 'tcolorbox' not found. See See #9 in FAQ-BUILD.txt" >&2
+	exit 1
+fi
+
 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
Signature · 1 line
2.17.1
#1 lore raw
Quoted 7 lines · Akira Yokosawa

"kpsewhich tcolorbox.sty" can be empty if tcolorbox is not available.

If this is the case, "grep" in grep ProvidePackage | sed ... will wait forever.

Add an empty check in front of "grep" with exit code of 1.

Paul,

Please ignore this patch.
I'll respin soon.

Sorry for the noise.

-- Akira

Quoted 26 lines
Fixes b2f19231bcc5 ("utilities/autodate.sh: Make newer tcolorbox behave as before")
---
 utilities/autodate.sh | 7 +++++++
 1 file changed, 7 insertions(+)
utilities/autodate.sh +7 -0
index 7bd7cbb8..2b9c1117 100644
@@ -97,6 +97,13 @@ env printf '\\IfQqzBg{}{\\setboolean{qqzbg}{%s}}\n' $qqzbg
 
 # command for newer tcolorbox (4.40 or later) to have backward-compatible skips
 tcolorbox_sty=`kpsewhich tcolorbox.sty`
+
+if [ "$tcolorbox_sty" == "" ]
+then
+	echo "Error: package 'tcolorbox' not found. See See #9 in FAQ-BUILD.txt" >&2
+	exit 1
+fi
+
 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
#4 lore raw

PATCH v2 1/1 utilities/autodate.sh: Fix potential hung-up on missing tcolorbox

In reply to Akira Yokosawa

"kpsewhich tcolorbox.sty" can be empty if tcolorbox is not available.

If this is the case, "grep" in grep ProvidePackage | sed ... will wait forever.

Add an empty check in front of "grep" with exit code of 1.

Fixes b2f19231bcc5 ("utilities/autodate.sh: Make newer tcolorbox behave as before")

---
Change since v1:

o Fix string comparison operator of shell script ("=")

--
utilities/autodate.sh | 7 +++++++

 1 file changed, 7 insertions(+)
utilities/autodate.sh +7 -0
index 7bd7cbb8..acf3b051 100644
@@ -97,6 +97,13 @@ env printf '\\IfQqzBg{}{\\setboolean{qqzbg}{%s}}\n' $qqzbg
 
 # command for newer tcolorbox (4.40 or later) to have backward-compatible skips
 tcolorbox_sty=`kpsewhich tcolorbox.sty`
+
+if [ "$tcolorbox_sty" = "" ]
+then
+	echo "Error: package 'tcolorbox' not found. See See #9 in FAQ-BUILD.txt" >&2
+	exit 1
+fi
+
 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
Signature · 1 line
2.17.1
#5 lore raw

PATCH v3 1/1 utilities/autodate.sh: Fix potential hung-up on missing tcolorbox

In reply to Akira Yokosawa

"kpsewhich tcolorbox.sty" can be empty if tcolorbox is not available.

If this is the case, "grep" in grep ProvidePackage | sed ... will wait forever.

Add an empty check in front of "grep" with exit code of 1.

Fixes b2f19231bcc5 ("utilities/autodate.sh: Make newer tcolorbox behave as before")

---
Change since v2:

o Refer to #5 in FAQ-BUILD.txt, as tcolorbox is not a font package.

Change since v1:

o Fix string comparison operator of shell script ("=").

--
utilities/autodate.sh | 7 +++++++

 1 file changed, 7 insertions(+)
utilities/autodate.sh +7 -0
index 7bd7cbb8..7d00738f 100644
@@ -97,6 +97,13 @@ env printf '\\IfQqzBg{}{\\setboolean{qqzbg}{%s}}\n' $qqzbg
 
 # command for newer tcolorbox (4.40 or later) to have backward-compatible skips
 tcolorbox_sty=`kpsewhich tcolorbox.sty`
+
+if [ "$tcolorbox_sty" = "" ]
+then
+	echo "Error: package 'tcolorbox' not found. See See #5 in FAQ-BUILD.txt" >&2
+	exit 1
+fi
+
 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
Signature · 1 line
2.17.1
#2 lore raw
In reply to Akira Yokosawa
Quoted 7 lines · Akira Yokosawa
Quoted 6 lines · Akira Yokosawa

"kpsewhich tcolorbox.sty" can be empty if tcolorbox is not available.

If this is the case, "grep" in grep ProvidePackage | sed ... will wait forever.

Quoted 8 lines
Quoted 1 line

Add an empty check in front of "grep" with exit code of 1.

Paul,

Please ignore this patch.
I'll respin soon.

Sorry for the noise.

Ignored, and no problem! Been there, done that! ;-)

Thanx, Paul

Quoted 29 lines

-- Akira

Quoted 26 lines
Fixes b2f19231bcc5 ("utilities/autodate.sh: Make newer tcolorbox behave as before")
---
 utilities/autodate.sh | 7 +++++++
 1 file changed, 7 insertions(+)
utilities/autodate.sh +7 -0
index 7bd7cbb8..2b9c1117 100644
@@ -97,6 +97,13 @@ env printf '\\IfQqzBg{}{\\setboolean{qqzbg}{%s}}\n' $qqzbg
 
 # command for newer tcolorbox (4.40 or later) to have backward-compatible skips
 tcolorbox_sty=`kpsewhich tcolorbox.sty`
+
+if [ "$tcolorbox_sty" == "" ]
+then
+	echo "Error: package 'tcolorbox' not found. See See #9 in FAQ-BUILD.txt" >&2
+	exit 1
+fi
+
 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
#6 lore raw

PATCH v4 1/1 utilities/autodate.sh: Fix potential hung-up on missing tcolorbox

In reply to Akira Yokosawa

"kpsewhich tcolorbox.sty" can be empty if tcolorbox is not available.

If this is the case, "grep" in grep ProvidePackage | sed ... will wait forever.

Add existence check of tcolorbox early in the script and error-exit.

To prevent empty autodate.tex from left behind, modify the behavior of the script so that it doesn't rely on the redirection in Makefile.

Fixes b2f19231bcc5 ("utilities/autodate.sh: Make newer tcolorbox behave as before")

---
Changes since v3:

o Fix typo of "See See" in the error message.
o Move existence check of tcolorbox to the beginning.
o Use redirection in the script, not in the Makefile

Change since v2:

o Refer to #5 in FAQ-BUILD.txt, as tcolorbox is not a font package.

Change since v1:

o Fix string comparison operator of shell script ("=").

--

 Makefile              |  2 +-
 utilities/autodate.sh | 24 ++++++++++++++++--------
 2 files changed, 17 insertions(+), 9 deletions(-)
Makefile +1 -1
index dc6b68e0..b23a7096 100644
@@ -234,7 +234,7 @@ endif
 autodate.tex: perfbook-lt.tex $(LATEXSOURCES) $(BIBSOURCES) \
     $(PDFTARGETS_OF_EPS) $(PDFTARGETS_OF_SVG) $(FCVSNIPPETS) $(FCVSNIPPETS_VIA_LTMS) \
     $(GITREFSTAGS) utilities/autodate.sh
-	sh utilities/autodate.sh >autodate.tex
+	sh utilities/autodate.sh
 
 perfbook_flat.tex: autodate.tex
 ifndef LATEXPAND
utilities/autodate.sh +16 -8
index 7bd7cbb8..e33c254d 100644
@@ -19,12 +19,21 @@
 # along with this program; if not, you can access it online at
 # http://www.gnu.org/licenses/gpl-2.0.html.
 #
-# Copyright (C) Akira Yokosawa, 2017--2020
+# Copyright (C) Akira Yokosawa, 2017--2021
 #
 # Authors: Akira Yokosawa <[email protected]>
 
 export LC_TIME=C
 qqzbg="false"
+fn="autodate.tex"
+
+# check if we have tcolorbox
+tcolorbox_sty=`kpsewhich tcolorbox.sty`
+if [ "$tcolorbox_sty" = "" ]
+then
+	echo "Error: package 'tcolorbox' not found. See #5 in FAQ-BUILD.txt." >&2
+	exit 1
+fi
 
 # check if we are in git repository
 if ! test -e .git
@@ -90,17 +99,16 @@ then
 	release=`env printf '%s %s' '\\\\' "$release"`
 fi
 
-env printf '\\date{%s %s, %s %s %s}\n' $month $day $year "$release" $modified
-env printf '\\newcommand{\\commityear}{%s}\n' $year
-env printf '\\newcommand{\\commitid}{%s}\n' $commitid$modified
-env printf '\\IfQqzBg{}{\\setboolean{qqzbg}{%s}}\n' $qqzbg
+env printf '\\date{%s %s, %s %s %s}\n' $month $day $year "$release" $modified > $fn
+env printf '\\newcommand{\\commityear}{%s}\n' $year >> $fn
+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
-tcolorbox_sty=`kpsewhich tcolorbox.sty`
 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
+env printf '%% tcolorbox version: %s\n' $tcbversion >> $fn
 if [ $(echo $tcbversion $tcbold | awk '{if ($1 > $2) print 1;}') ] ;
 then
-	env printf '\\tcbsetforeverylayer{autoparskip}\n';
+	env printf '\\tcbsetforeverylayer{autoparskip}\n' >> $fn
 fi
Signature · 1 line
2.17.1
#3 lore raw
In reply to Paul E. McKenney
Quoted 10 lines · Paul E. McKenney
Quoted 9 lines · Akira Yokosawa
Quoted 7 lines · Akira Yokosawa

"kpsewhich tcolorbox.sty" can be empty if tcolorbox is not available.

If this is the case, "grep" in grep ProvidePackage | sed ... will wait forever.

Add an empty check in front of "grep" with exit code of 1.

Quoted 8 lines
Quoted 6 lines

Paul,

Please ignore this patch.
I'll respin soon.

Sorry for the noise.

Ignored, and no problem! Been there, done that! ;-)

Patch v4 I just sent out should be good enough.
I'm afraid you don't have a handy environment to test the error path, but I did uninstall texlive-tcolorbox on a Fedora container and confirmed the error check works as expected.

Thanks, Akira

Quoted 32 lines

Thanx, Paul

Quoted 29 lines

-- Akira

Quoted 26 lines
Fixes b2f19231bcc5 ("utilities/autodate.sh: Make newer tcolorbox behave as before")
---
 utilities/autodate.sh | 7 +++++++
 1 file changed, 7 insertions(+)
utilities/autodate.sh +7 -0
index 7bd7cbb8..2b9c1117 100644
@@ -97,6 +97,13 @@ env printf '\\IfQqzBg{}{\\setboolean{qqzbg}{%s}}\n' $qqzbg
 
 # command for newer tcolorbox (4.40 or later) to have backward-compatible skips
 tcolorbox_sty=`kpsewhich tcolorbox.sty`
+
+if [ "$tcolorbox_sty" == "" ]
+then
+	echo "Error: package 'tcolorbox' not found. See See #9 in FAQ-BUILD.txt" >&2
+	exit 1
+fi
+
 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
#7 lore raw
In reply to Akira Yokosawa
Quoted 6 lines · Akira Yokosawa

"kpsewhich tcolorbox.sty" can be empty if tcolorbox is not available.

If this is the case, "grep" in grep ProvidePackage | sed ... will wait forever.

Quoted 7 lines

Add existence check of tcolorbox early in the script and error-exit.

To prevent empty autodate.tex from left behind, modify the behavior of the script so that it doesn't rely on the redirection in Makefile.

Fixes b2f19231bcc5 ("utilities/autodate.sh: Make newer tcolorbox behave as before")

Queued and pushed, thank you!

Thanx, Paul

Quoted 88 lines

---
Changes since v3:

o Fix typo of "See See" in the error message.
o Move existence check of tcolorbox to the beginning.
o Use redirection in the script, not in the Makefile

Change since v2:

o Refer to #5 in FAQ-BUILD.txt, as tcolorbox is not a font package.

Change since v1:

o Fix string comparison operator of shell script ("=").

--

 Makefile              |  2 +-
 utilities/autodate.sh | 24 ++++++++++++++++--------
 2 files changed, 17 insertions(+), 9 deletions(-)
Makefile +1 -1
index dc6b68e0..b23a7096 100644
@@ -234,7 +234,7 @@ endif
 autodate.tex: perfbook-lt.tex $(LATEXSOURCES) $(BIBSOURCES) \
     $(PDFTARGETS_OF_EPS) $(PDFTARGETS_OF_SVG) $(FCVSNIPPETS) $(FCVSNIPPETS_VIA_LTMS) \
     $(GITREFSTAGS) utilities/autodate.sh
-	sh utilities/autodate.sh >autodate.tex
+	sh utilities/autodate.sh
 
 perfbook_flat.tex: autodate.tex
 ifndef LATEXPAND
utilities/autodate.sh +16 -8
index 7bd7cbb8..e33c254d 100644
@@ -19,12 +19,21 @@
 # along with this program; if not, you can access it online at
 # http://www.gnu.org/licenses/gpl-2.0.html.
 #
-# Copyright (C) Akira Yokosawa, 2017--2020
+# Copyright (C) Akira Yokosawa, 2017--2021
 #
 # Authors: Akira Yokosawa <[email protected]>
 
 export LC_TIME=C
 qqzbg="false"
+fn="autodate.tex"
+
+# check if we have tcolorbox
+tcolorbox_sty=`kpsewhich tcolorbox.sty`
+if [ "$tcolorbox_sty" = "" ]
+then
+	echo "Error: package 'tcolorbox' not found. See #5 in FAQ-BUILD.txt." >&2
+	exit 1
+fi
 
 # check if we are in git repository
 if ! test -e .git
@@ -90,17 +99,16 @@ then
 	release=`env printf '%s %s' '\\\\' "$release"`
 fi
 
-env printf '\\date{%s %s, %s %s %s}\n' $month $day $year "$release" $modified
-env printf '\\newcommand{\\commityear}{%s}\n' $year
-env printf '\\newcommand{\\commitid}{%s}\n' $commitid$modified
-env printf '\\IfQqzBg{}{\\setboolean{qqzbg}{%s}}\n' $qqzbg
+env printf '\\date{%s %s, %s %s %s}\n' $month $day $year "$release" $modified > $fn
+env printf '\\newcommand{\\commityear}{%s}\n' $year >> $fn
+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
-tcolorbox_sty=`kpsewhich tcolorbox.sty`
 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
+env printf '%% tcolorbox version: %s\n' $tcbversion >> $fn
 if [ $(echo $tcbversion $tcbold | awk '{if ($1 > $2) print 1;}') ] ;
 then
-	env printf '\\tcbsetforeverylayer{autoparskip}\n';
+	env printf '\\tcbsetforeverylayer{autoparskip}\n' >> $fn
 fi
Signature · 1 line
2.17.1