[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 01/03: pic2graph: Handle embedded whitespace in temp dir.
From: |
G. Branden Robinson |
Subject: |
[groff] 01/03: pic2graph: Handle embedded whitespace in temp dir. |
Date: |
Wed, 25 Apr 2018 10:21:17 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 266bf8ff4f80024710462d6996cae2db97406c3b
Author: G. Branden Robinson <address@hidden>
Date: Wed Apr 25 00:34:44 2018 -0400
pic2graph: Handle embedded whitespace in temp dir.
contrib/pic2graph/pic2graph.sh: Quote shell variables having to do with
the temporary directory's location; without quotation, temporary
directory names with embedded whitespace are wrongly handled.
Test case:
GROFF_TMPDIR="/tmp/My Documents" ./build/pic2graph < pic >| pic.png
Not all shell variables should be quoted, especially not blindly, but
this one should be.
Signed-off-by: G. Branden Robinson <address@hidden>
---
ChangeLog | 9 +++++++++
contrib/pic2graph/pic2graph.sh | 14 +++++++-------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c6e63f1..548a70e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2018-04-25 G. Branden Robinson <address@hidden>
+
+ pic2graph: Handle embedded whitespace in temp dir.
+
+ contrib/pic2graph/pic2graph.sh: Quote shell variables having to
+ do with the temporary directory's location; without quotation,
+ temporary directory names with embedded whitespace are wrongly
+ handled.
+
2018-04-24 G. Branden Robinson <address@hidden>
* doc/groff.texi: Bump end of copyright range to 2018. Werner
diff --git a/contrib/pic2graph/pic2graph.sh b/contrib/pic2graph/pic2graph.sh
index 7773b26..97b486e 100644
--- a/contrib/pic2graph/pic2graph.sh
+++ b/contrib/pic2graph/pic2graph.sh
@@ -75,8 +75,8 @@ for d in "$GROFF_TMPDIR" "$TMPDIR" "$TMP" "$TEMP" /tmp; do
&& test -n "$tmp" && test -d "$tmp" \
&& break
- tmp=$d/pic2graph$$-$RANDOM
- (umask 077 && mkdir $tmp) 2> /dev/null \
+ tmp="$d/pic2graph$$-$RANDOM"
+ (umask 077 && mkdir "$tmp") 2> /dev/null \
&& break
done;
if test -z "$tmp"; then
@@ -93,7 +93,7 @@ then
convert_trim_arg="-crop 0x0"
fi
-trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' EXIT INT TERM
+trap 'exit_status=$?; rm -rf "$tmp" && exit $exit_status' EXIT INT TERM
# Here goes:
# 1. Wrap the input in dummy .PS/PE macros (and add possibly null .EQ/.EN)
@@ -101,9 +101,9 @@ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status'
EXIT INT TERM
# 3. Process through groff to emit Postscript.
# 4. Use convert(1) to crop the PostScript and turn it into a bitmap.
(echo ".EQ"; echo $eqndelim; echo ".EN"; echo ".PS"; cat; echo ".PE") | \
- groff -e -p $groffpic_opts -Tps -P-pletter > $tmp/pic2graph.ps \
- && convert $convert_trim_arg $convert_opts $tmp/pic2graph.ps \
- $tmp/pic2graph.$format \
- && cat $tmp/pic2graph.$format
+ groff -e -p $groffpic_opts -Tps -P-pletter > "$tmp"/pic2graph.ps \
+ && convert $convert_trim_arg $convert_opts "$tmp"/pic2graph.ps \
+ "$tmp"/pic2graph.$format \
+ && cat "$tmp"/pic2graph.$format
# End
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 01/03: pic2graph: Handle embedded whitespace in temp dir.,
G. Branden Robinson <=