Blame SOURCES/covscan.patch

0b392c
diff --git a/tools/yelp-build.in b/tools/yelp-build.in
0b392c
index 898325b..0397410 100755
0b392c
--- a/tools/yelp-build.in
0b392c
+++ b/tools/yelp-build.in
0b392c
@@ -32,7 +32,7 @@ xsl_mal_files='@DATADIR@/xslt/mal-files.xsl'
0b392c
 
0b392c
 mkdir_p () {
0b392c
     if [ ! -d "$1" ]; then
0b392c
-        mkdir_p `dirname "$1"`
0b392c
+        mkdir_p "$(dirname "$1")"
0b392c
         mkdir "$1"
0b392c
     fi
0b392c
 }
0b392c
@@ -154,7 +154,7 @@ yelp_paths_normalize () {
0b392c
 
0b392c
 yelp_cache_in_page () {
0b392c
     fbase=$(basename "$1")
0b392c
-    fdir=$( (cd $(dirname "$1") && pwd) )
0b392c
+    fdir=$( (cd "$(dirname "$1")" && pwd) )
0b392c
     sdir=${fdir##${cache_site_root}}/
0b392c
     url=file://$(echo "$fdir/$fbase" | urlencode)
0b392c
     if [ "x$cache_site" = "x1" ]; then
0b392c
@@ -166,7 +166,7 @@ yelp_cache_in_page () {
0b392c
 yelp_cache_in_site () {
0b392c
     for dir in "$1"/*; do
0b392c
         if [ -d "$dir" ]; then
0b392c
-            if [ $(basename "$dir") != "__pintail__" ]; then
0b392c
+            if [ "$(basename "$dir")" != "__pintail__" ]; then
0b392c
                 yelp_cache_in_site "$dir"
0b392c
             fi
0b392c
         fi
0b392c
@@ -219,7 +219,7 @@ yelp_cache () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] ||[ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_cache
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -237,10 +237,10 @@ yelp_html_xsl_common () {
0b392c
         echo '<xsl:variable name="yelp.internal.datadir" select="'"''"'"/>'
0b392c
     fi
0b392c
     if [ "x$html_internal_xsl" != "x" ]; then
0b392c
-        echo '<xsl:include href="file://'`echo "$html_internal_xsl" | urlencode`'"/>'
0b392c
+        echo '<xsl:include href="file://'"$(echo "$html_internal_xsl" | urlencode)"'"/>'
0b392c
     fi
0b392c
     if [ "x$html_custom" != "x" ]; then
0b392c
-        echo '<xsl:include href="file://'`echo "$html_custom" | urlencode`'"/>'
0b392c
+        echo '<xsl:include href="file://'"$(echo "$html_custom" | urlencode)"'"/>'
0b392c
     fi
0b392c
     echo '<xsl:template name="html.css">'
0b392c
     echo ' <xsl:param name="node" select="."/>'
0b392c
@@ -281,8 +281,8 @@ yelp_html_xsl_common () {
0b392c
 }
0b392c
 yelp_html_db2html () {
0b392c
     for xml in "$@"; do
0b392c
-        xmldir=`dirname "$xml"`
0b392c
-        xmldir=`(cd "$xmldir" && pwd)`
0b392c
+        xmldir=$(dirname "$xml")
0b392c
+        xmldir=$( (cd "$xmldir" && pwd))
0b392c
         # Output HTML
0b392c
         (
0b392c
             echo '
0b392c
@@ -292,9 +292,9 @@ yelp_html_db2html () {
0b392c
             echo ' extension-element-prefixes="exsl"'
0b392c
             echo ' version="1.0">'
0b392c
             if [ "x$is_xhtml" = "x1" ]; then
0b392c
-                xsl='file://'`echo "$xsl_db2xhtml" | urlencode`
0b392c
+                xsl='file://'$(echo "$xsl_db2xhtml" | urlencode)
0b392c
             else
0b392c
-                xsl='file://'`echo "$xsl_db2html" | urlencode`
0b392c
+                xsl='file://'$(echo "$xsl_db2html" | urlencode)
0b392c
             fi
0b392c
             echo '<xsl:import href="'"$xsl"'"/>'
0b392c
             yelp_html_xsl_common
0b392c
@@ -317,12 +317,12 @@ yelp_html_db2html () {
0b392c
                 echo ' </xsl:for-each>'
0b392c
                 echo '</xsl:template>'
0b392c
                 echo '</xsl:stylesheet>'
0b392c
-            ) | xsltproc --path "$html_paths" --xinclude - "$xml" | while read media; do
0b392c
-                mfile=`echo "$media" | urldecode`
0b392c
+            ) | xsltproc --path "$html_paths" --xinclude - "$xml" | while read -r media; do
0b392c
+                mfile=$(echo "$media" | urldecode)
0b392c
                 minput="$xmldir/$mfile"
0b392c
                 moutput="$html_out/$mfile"
0b392c
-                mkdir_p `dirname "$moutput"`
0b392c
-                if [ ! -f "$minput" -a "x$html_paths" != "x" ]; then
0b392c
+                mkdir_p "$(dirname "$moutput")"
0b392c
+                if [ ! -f "$minput" ] && [ "x$html_paths" != "x" ]; then
0b392c
                     minput_rel=${minput#"$(pwd)/"}
0b392c
                     if [ "x$minput_rel" != "x$minput_src" ]; then
0b392c
                         for path in $html_paths; do
0b392c
@@ -333,7 +333,7 @@ yelp_html_db2html () {
0b392c
                         done
0b392c
                     fi
0b392c
                 fi
0b392c
-                if [ -f "$minput" -o "x$html_ignore_media" != "x1" ]; then
0b392c
+                if [ -f "$minput" ] || [ "x$html_ignore_media" != "x1" ]; then
0b392c
                     cp "$minput" "$moutput"
0b392c
                 fi
0b392c
             done
0b392c
@@ -345,13 +345,13 @@ yelp_html_db2html () {
0b392c
 
0b392c
 yelp_html_mal2html () {
0b392c
     if [ "x$html_cache_file" != "x" ]; then
0b392c
-        html_cache_file=`(cd $(dirname "$html_cache_file") && pwd)`/`basename "$html_cache_file"`
0b392c
+        html_cache_file=$( (cd "$(dirname "$html_cache_file")" && pwd))/$(basename "$html_cache_file")
0b392c
     else
0b392c
         html_cache_file_is_tmp="yes"
0b392c
-        html_cache_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+        html_cache_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
         yelp_cache -o "$html_cache_file" "$@"
0b392c
     fi
0b392c
-    html_tmp_infile=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+    html_tmp_infile=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
     yelp_cache_in "$@" > "$html_tmp_infile"
0b392c
     # Output HTML
0b392c
     (
0b392c
@@ -365,15 +365,15 @@ yelp_html_mal2html () {
0b392c
         echo ' extension-element-prefixes="exsl"'
0b392c
         echo ' version="1.0">'
0b392c
         if [ "x$is_xhtml" = "x1" ]; then
0b392c
-            xsl='file://'`echo "$xsl_mal2xhtml" | urlencode`
0b392c
+            xsl='file://'$(echo "$xsl_mal2xhtml" | urlencode)
0b392c
         else
0b392c
-            xsl='file://'`echo "$xsl_mal2html" | urlencode`
0b392c
+            xsl='file://'$(echo "$xsl_mal2html" | urlencode)
0b392c
         fi
0b392c
         echo '<xsl:import href="'"$xsl"'"/>'
0b392c
         echo '<xsl:include href="'"$xsl_mal_files"'"/>'
0b392c
         echo '<xsl:output method="text"/>'
0b392c
         yelp_html_xsl_common
0b392c
-        html_cache_url='file://'`echo "$html_cache_file" | urlencode`
0b392c
+        html_cache_url='file://'$(echo "$html_cache_file" | urlencode)
0b392c
         echo '<xsl:param name="mal.cache.file" select="'"'$html_cache_url'"'"/>'
0b392c
         echo '<xsl:template match="/">'
0b392c
         echo '<xsl:for-each select="cache:cache/mal:page">'
0b392c
@@ -387,14 +387,14 @@ yelp_html_mal2html () {
0b392c
         echo '</xsl:for-each>'
0b392c
         echo '</xsl:template>'
0b392c
         echo '</xsl:stylesheet>'
0b392c
-    ) | (cd "$html_out" && xsltproc $html_profile \
0b392c
+    ) | (cd "$html_out" && xsltproc "$html_profile" \
0b392c
         --path "$html_paths" --xinclude \
0b392c
         - "$html_tmp_infile") | sort | uniq | \
0b392c
-    while read line; do
0b392c
+    while read -r line; do
0b392c
         # Copy media from paths output by HTML transform
0b392c
         line_src=$(echo "$line" | cut -d' ' -f1 | urldecode)
0b392c
         line_dest="$html_out/"$(echo "$line" | cut -d' ' -f2)
0b392c
-        if [ ! -f "$line_src" -a "x$html_paths" != "x" ]; then
0b392c
+        if [ ! -f "$line_src" ] && [ "x$html_paths" != "x" ]; then
0b392c
             line_src_rel=${line_src#"$(pwd)/"}
0b392c
             if [ "x$line_src_rel" != "x$line_src" ]; then
0b392c
                 for path in $html_paths; do
0b392c
@@ -405,11 +405,11 @@ yelp_html_mal2html () {
0b392c
                 done
0b392c
             fi
0b392c
         fi
0b392c
-        line_dest=`echo "$line_dest" | urldecode`
0b392c
+        line_dest=$(echo "$line_dest" | urldecode)
0b392c
         if [ "$line_src" != "$line_dest" ]; then
0b392c
-            line_dir=`dirname "$line_dest"`
0b392c
+            line_dir=$(dirname "$line_dest")
0b392c
             mkdir_p "$line_dir"
0b392c
-            if [ -f "$line_src" -o "x$html_ignore_media" != "x1" ]; then
0b392c
+            if [ -f "$line_src" ] || [ "x$html_ignore_media" != "x1" ]; then
0b392c
                 cp "$line_src" "$line_dest"
0b392c
             fi
0b392c
         fi
0b392c
@@ -465,18 +465,18 @@ yelp_html () {
0b392c
         echo "Error: output must be a directory." 1>&2
0b392c
         exit 1
0b392c
     fi
0b392c
-    html_out=`(cd "$html_out" && pwd)`
0b392c
+    html_out=$( (cd "$html_out" && pwd))
0b392c
     if [ "x$html_custom" != "x" ]; then
0b392c
-        html_custom_dir=`dirname "$html_custom"`
0b392c
-        html_custom_dir=`(cd "$html_custom_dir" && pwd)`
0b392c
-        html_custom="$html_custom_dir"/`basename "$html_custom"`
0b392c
+        html_custom_dir=$(dirname "$html_custom")
0b392c
+        html_custom_dir=$( (cd "$html_custom_dir" && pwd))
0b392c
+        html_custom="$html_custom_dir"/$(basename "$html_custom")
0b392c
     fi
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_html
0b392c
         exit 1
0b392c
     fi
0b392c
-    ext=`echo "$1" | sed -e 's/.*\.//'`
0b392c
-    if [ "x$ext" = "xxml" -o "x$ext" = "xdocbook" ]; then
0b392c
+    ext=$(echo "$1" | sed -e 's/.*\.//')
0b392c
+    if [ "x$ext" = "xxml" ] || [ "x$ext" = "xdocbook" ]; then
0b392c
         yelp_html_db2html "$@"
0b392c
     else
0b392c
         yelp_html_mal2html "$@"
0b392c
@@ -515,19 +515,19 @@ yelp_epub () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_epub
0b392c
         exit 1
0b392c
     fi
0b392c
     if [ "x$epub_cache_file" != "x" ]; then
0b392c
-        epub_cache_file=`(cd $(dirname "$epub_cache_file") && pwd)`/`basename "$epub_cache_file"`
0b392c
+        epub_cache_file=$( (cd "$(dirname "$epub_cache_file")" && pwd))/$(basename "$epub_cache_file")
0b392c
     else
0b392c
         epub_cache_file_is_tmp="yes"
0b392c
-        epub_cache_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+        epub_cache_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
         yelp_cache -o "$epub_cache_file" "$@"
0b392c
     fi
0b392c
     html_cache_file="$epub_cache_file"
0b392c
-    epub_data_out=`mktemp -d "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+    epub_data_out=$(mktemp -d "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
     html_out="$epub_data_out/OPS"
0b392c
     mkdir "$html_out"
0b392c
     mkdir "$html_out/yelp"
0b392c
@@ -535,8 +535,8 @@ yelp_epub () {
0b392c
     html_internal_xsl="$xsl_mal_epub"
0b392c
     yelp_html_mal2html "$@"
0b392c
 
0b392c
-    epub_id=`uuidgen`
0b392c
-    epub_data=`(cd "$html_out" && ls yelp/*.*)`
0b392c
+    epub_id=$(uuidgen)
0b392c
+    epub_data=$( (cd "$html_out" && ls yelp/*.*))
0b392c
     xsltproc \
0b392c
         --path "$html_paths" \
0b392c
         -o "$html_out/opf.opf" \
0b392c
@@ -562,9 +562,9 @@ yelp_epub () {
0b392c
     ) > "$epub_data_out/META-INF/container.xml"
0b392c
 
0b392c
     if [ "x$epub_out" = "x" ]; then
0b392c
-        epub_out=`pwd`/index.epub
0b392c
+        epub_out=$(pwd)/index.epub
0b392c
     else
0b392c
-        epub_out=`(cd $(dirname "$epub_out") && pwd)`/`basename "$epub_out"`
0b392c
+        epub_out=$( (cd "$(dirname "$epub_out")" && pwd))/$(basename "$epub_out")
0b392c
     fi
0b392c
     (cd "$epub_data_out" && zip -q -r "$epub_out" mimetype META-INF OPS)
0b392c
 
0b392c
diff --git a/tools/yelp-check.in b/tools/yelp-check.in
0b392c
index 526679d..6b1a595 100755
0b392c
--- a/tools/yelp-check.in
0b392c
+++ b/tools/yelp-check.in
0b392c
@@ -282,7 +282,7 @@ fi
0b392c
 yelp_check_iter_site () {
0b392c
     for dir in "$1"/*; do
0b392c
         if [ -d "$dir" ]; then
0b392c
-            if [ $(basename "$dir") != "__pintail__" ]; then
0b392c
+            if [ "$(basename "$dir")" != "__pintail__" ]; then
0b392c
                 yelp_check_iter_site "$dir"
0b392c
             fi
0b392c
         fi
0b392c
@@ -307,9 +307,9 @@ yelp_check_iter_args () {
0b392c
                     fi
0b392c
                 done
0b392c
             fi
0b392c
-        elif [ "x$ext" = "xpage" -o "x$ext" = "xstub" -o "x$ext" = "xcache" ]; then
0b392c
+        elif [ "x$ext" = "xpage" ] || [ "x$ext" = "xstub" ] || [ "x$ext" = "xcache" ]; then
0b392c
             $check_page "$arg" || yelp_check_retval="$?"
0b392c
-	elif [ "x$check_db" != "x" -a \( "x$ext" = "xdocbook" -o "x$ext" = "xxml" \) ]; then
0b392c
+        elif [ "x$check_db" != "x" ] && ([ "x$ext" = "xdocbook" ] || [ "x$ext" = "xxml" ]); then
0b392c
 	    $check_db "$arg" || yelp_check_retval="$?"
0b392c
         else
0b392c
             echo "Unrecognized page $arg" 1>&2
0b392c
@@ -322,7 +322,7 @@ yelp_check_iter_args () {
0b392c
 yelp_hrefs_page () {
0b392c
     base=$(dirname "$1")
0b392c
     if [ "x$check_site" = "x1" ]; then
0b392c
-        sdir=$(cd $(dirname "$1") && pwd)
0b392c
+        sdir=$(cd "$(dirname "$1")" && pwd)
0b392c
         sdir=${sdir##${check_site_root}}/
0b392c
     fi
0b392c
     (
0b392c
@@ -355,23 +355,23 @@ yelp_hrefs_page () {
0b392c
         echo '</xsl:template>'
0b392c
         echo '</xsl:stylesheet>'
0b392c
     ) | xsltproc --xinclude - "$1" | sort | uniq | \
0b392c
-        while read id url; do
0b392c
-            colon=`echo "$url" | cut -d: -f1`
0b392c
+        while read -r id url; do
0b392c
+            colon=$(echo "$url" | cut -d: -f1)
0b392c
             if [ "x$colon" = "x$url" ]; then
0b392c
-                test -f "$base/"$(urldecode "$url") || echo "$sdir$id: $url"
0b392c
+                test -f "$base/""$(urldecode "$url")" || echo "$sdir$id: $url"
0b392c
             else
0b392c
-                status=$(cat "$check_href_cache" | while read trystatus tryurl; do
0b392c
+                status=$(while read -r trystatus tryurl; do
0b392c
                                 if [ "x$tryurl" = "x$url" ]; then echo "$trystatus"; break; fi
0b392c
-                            done)
0b392c
+                            done < "$check_href_cache")
0b392c
                 if [ "x$status" = "x1" ]; then
0b392c
                     true
0b392c
                 elif [ "x$status" = "x0" ]; then
0b392c
                     echo "$sdir$id: $url"
0b392c
                 else
0b392c
-                    (curl -s -I -L "$url" | \
0b392c
+                    ( (curl -s -I -L "$url" | \
0b392c
                             grep '^HTTP/' | tail -n 1 | head -n 1 | \
0b392c
                             grep -q 'HTTP/.\.. 200 .*') \
0b392c
-                        && (echo "1 $url" >> "$check_href_cache") \
0b392c
+                        && (echo "1 $url" >> "$check_href_cache")) \
0b392c
                         || (echo "0 $url" >> "$check_href_cache"; echo "$sdir$id: $url")
0b392c
                 fi
0b392c
             fi
0b392c
@@ -379,7 +379,7 @@ yelp_hrefs_page () {
0b392c
 }
0b392c
 
0b392c
 yelp_hrefs () {
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_hrefs
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -395,12 +395,12 @@ yelp_hrefs () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_hrefs
0b392c
         exit 1
0b392c
     fi
0b392c
-    check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
-    check_href_cache=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+    check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
+    check_href_cache=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
     echo > "$check_href_cache"
0b392c
     check_db=yelp_hrefs_page
0b392c
     check_page=yelp_hrefs_page
0b392c
@@ -432,9 +432,9 @@ yelp_ids_page () {
0b392c
     bname=$(basename "$1")
0b392c
     if [ "x$pageid.page" != "x$bname" ]; then
0b392c
 	if [ "x$check_site" = "x1" ]; then
0b392c
-            sdir=$(cd $(dirname "$1") && pwd)
0b392c
+            sdir=$(cd "$(dirname "$1")" && pwd)
0b392c
             sdir=${sdir##${check_site_root}}/
0b392c
-            echo $sdir$(basename "$1")": $pageid"
0b392c
+            echo "$sdir$(basename "$1"): $pageid"
0b392c
 	elif [ "x$dname" = 'x.' ]; then
0b392c
             echo "$bname: $pageid"
0b392c
         else
0b392c
@@ -445,7 +445,7 @@ yelp_ids_page () {
0b392c
 }
0b392c
 
0b392c
 yelp_ids () {
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_ids
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -461,7 +461,7 @@ yelp_ids () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_ids
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -497,7 +497,7 @@ yelp_links_db () {
0b392c
 
0b392c
 yelp_links_page () {
0b392c
     if [ "x$check_site" = "x1" ]; then
0b392c
-        sdir=$(cd $(dirname "$1") && pwd)
0b392c
+        sdir=$(cd "$(dirname "$1")" && pwd)
0b392c
         sdir=${sdir##${check_site_root}}/
0b392c
     fi
0b392c
     (
0b392c
@@ -508,9 +508,9 @@ yelp_links_page () {
0b392c
         echo ' xmlns:exsl="http://exslt.org/common"'
0b392c
         echo ' extension-element-prefixes="exsl"'
0b392c
         echo ' version="1.0">'
0b392c
-        xsl='file://'`urlencode "$xsl_mal_link"`
0b392c
+        xsl='file://'$(urlencode "$xsl_mal_link")
0b392c
         echo '<xsl:import href="'"$xsl"'"/>'
0b392c
-        check_cache_url='file://'`urlencode "$check_cache_file"`
0b392c
+        check_cache_url='file://'$(urlencode "$check_cache_file")
0b392c
         echo '<xsl:param name="mal.cache.file" select="'"'$check_cache_url'"'"/>'
0b392c
         echo '<xsl:variable name="site.dir" select="'"'$sdir'"'"/>'
0b392c
         echo '<xsl:output method="text"/>'
0b392c
@@ -544,7 +544,7 @@ yelp_links_page () {
0b392c
 }
0b392c
 
0b392c
 yelp_links () {
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_links
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -569,7 +569,7 @@ yelp_links () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_links
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -585,7 +585,7 @@ yelp_links () {
0b392c
                 check_cache_file=1
0b392c
                 ;;
0b392c
             *)
0b392c
-                break
0b392c
+                return
0b392c
                 ;;
0b392c
         esac
0b392c
     fi
0b392c
@@ -599,7 +599,7 @@ yelp_links () {
0b392c
         fi
0b392c
     fi
0b392c
 
0b392c
-    check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+    check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
     check_db=yelp_links_db
0b392c
     check_page=yelp_links_page
0b392c
     yelp_check_iter_args "$@" > "$check_out_file"
0b392c
@@ -632,7 +632,7 @@ yelp_media_page () {
0b392c
     fi
0b392c
     xsltproc "$xsl_media" "$1" | \
0b392c
         sort | uniq | \
0b392c
-        while read line; do
0b392c
+        while read -r line; do
0b392c
             src=$(urldecode "$line")
0b392c
             if [ ! -f "$dname$src" ]; then
0b392c
                 echo "$sdir$bname: $line"
0b392c
@@ -641,7 +641,7 @@ yelp_media_page () {
0b392c
 }
0b392c
 
0b392c
 yelp_media () {
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_media
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -657,11 +657,11 @@ yelp_media () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_media
0b392c
         exit 1
0b392c
     fi
0b392c
-    check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+    check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
     check_db=yelp_media_page
0b392c
     check_page=yelp_media_page
0b392c
     yelp_check_iter_args "$@" > "$check_out_file"
0b392c
@@ -676,7 +676,7 @@ yelp_media () {
0b392c
 
0b392c
 yelp_orphans_page () {
0b392c
     if [ "x$check_site" = "x1" ]; then
0b392c
-        sdir=$(cd $(dirname "$1") && pwd)
0b392c
+        sdir=$(cd "$(dirname "$1")" && pwd)
0b392c
         sdir=${sdir##${check_site_root}}/
0b392c
     fi
0b392c
     (
0b392c
@@ -686,9 +686,9 @@ yelp_orphans_page () {
0b392c
         echo ' xmlns:exsl="http://exslt.org/common"'
0b392c
         echo ' extension-element-prefixes="exsl"'
0b392c
         echo ' version="1.0">'
0b392c
-        xsl='file://'`urlencode "$xsl_mal_link"`
0b392c
+        xsl='file://'$(urlencode "$xsl_mal_link")
0b392c
         echo '<xsl:import href="'"$xsl"'"/>'
0b392c
-        check_cache_url='file://'`urlencode "$check_cache_file"`
0b392c
+        check_cache_url='file://'$(urlencode "$check_cache_file")
0b392c
         echo '<xsl:param name="mal.cache.file" select="'"'$check_cache_url'"'"/>'
0b392c
         echo '<xsl:variable name="site.dir" select="'"'$sdir'"'"/>'
0b392c
         echo '<xsl:output method="text"/>'
0b392c
@@ -707,7 +707,7 @@ yelp_orphans_page () {
0b392c
 }
0b392c
 
0b392c
 yelp_orphans () {
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_orphans
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -728,7 +728,7 @@ yelp_orphans () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_orphans
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -744,7 +744,7 @@ yelp_orphans () {
0b392c
                 check_cache_file=1
0b392c
                 ;;
0b392c
             *)
0b392c
-                break
0b392c
+                return
0b392c
                 ;;
0b392c
         esac
0b392c
     fi
0b392c
@@ -758,7 +758,7 @@ yelp_orphans () {
0b392c
         fi
0b392c
     fi
0b392c
 
0b392c
-    check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+    check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
     check_db=
0b392c
     check_page=yelp_orphans_page
0b392c
     yelp_check_iter_args "$@" > "$check_out_file"
0b392c
@@ -778,7 +778,7 @@ yelp_comments_page () {
0b392c
     ext=$(echo "$1" | sed -e 's/.*\.//')
0b392c
     bname=$(basename "$1" ".$ext")
0b392c
     if [ "x$check_site" = "x1" ]; then
0b392c
-        sdir=$(cd $(dirname "$1") && pwd)
0b392c
+        sdir=$(cd "$(dirname "$1")" && pwd)
0b392c
         sdir=${sdir##${check_site_root}}/
0b392c
     fi
0b392c
     xsltproc --stringparam basename "$bname" \
0b392c
@@ -787,7 +787,7 @@ yelp_comments_page () {
0b392c
 }
0b392c
 
0b392c
 yelp_comments () {
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_comments
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -803,7 +803,7 @@ yelp_comments () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_comments
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -815,7 +815,7 @@ yelp_comments () {
0b392c
 
0b392c
 yelp_license_page () {
0b392c
     if [ "x$check_site" = "x1" ]; then
0b392c
-        sdir=$(cd $(dirname "$1") && pwd)
0b392c
+        sdir=$(cd "$(dirname "$1")" && pwd)
0b392c
         sdir=${sdir##${check_site_root}}/
0b392c
     fi
0b392c
     xsltproc --xinclude \
0b392c
@@ -827,7 +827,7 @@ yelp_license_page () {
0b392c
 }
0b392c
 
0b392c
 yelp_license () {
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_license
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -857,7 +857,7 @@ yelp_license () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_license
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -875,7 +875,7 @@ yelp_style_page () {
0b392c
     ext=$(echo "$1" | sed -e 's/.*\.//')
0b392c
     bname=$(basename "$1" ".$ext")
0b392c
     if [ "x$check_site" = "x1" ]; then
0b392c
-        sdir=$(cd $(dirname "$1") && pwd)
0b392c
+        sdir=$(cd "$(dirname "$1")" && pwd)
0b392c
         sdir=${sdir##${check_site_root}}/
0b392c
     fi
0b392c
     style=$(echo "$mallard_style" | xsltproc - "$1")
0b392c
@@ -886,7 +886,7 @@ yelp_style_page () {
0b392c
             # We treat an empty --only '' as requesting pages with no style
0b392c
             if [ "x$style" = "x" ]; then output=1; fi
0b392c
         else
0b392c
-            for pstyle in "$style"; do
0b392c
+            for pstyle in $style; do
0b392c
                 for sstyle in $(echo "$check_only" | sed -e 's/,/ /g'); do
0b392c
                     if [ "$pstyle" = "$sstyle" ]; then
0b392c
                         output=1
0b392c
@@ -902,7 +902,7 @@ yelp_style_page () {
0b392c
             # We treat an empty --except '' as excluding pages with no style
0b392c
             if [ "x$style" = "x" ]; then output=0; fi
0b392c
         else
0b392c
-            for pstyle in "$style"; do
0b392c
+            for pstyle in $style; do
0b392c
                 for sstyle in $(echo "$check_except" | sed -e 's/,/ /g'); do
0b392c
                     if [ "$pstyle" = "$sstyle" ]; then
0b392c
                         output=0
0b392c
@@ -919,7 +919,7 @@ yelp_style_page () {
0b392c
 }
0b392c
 
0b392c
 yelp_style () {
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_style
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -951,7 +951,7 @@ yelp_style () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_style
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -959,7 +959,7 @@ yelp_style () {
0b392c
     check_page=yelp_style_page
0b392c
     if [ "x$check_totals" = "x1" ]; then
0b392c
         yelp_check_iter_args "$@" | \
0b392c
-            while read line; do
0b392c
+            while read -r line; do
0b392c
                 styles=$(echo "$line" | sed -e 's/^[^:]*://')
0b392c
                 if [ "x$styles" = "x" ]; then
0b392c
                     echo ""
0b392c
@@ -976,7 +976,7 @@ yelp_style () {
0b392c
 }
0b392c
 
0b392c
 yelp_status () {
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_status
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -1031,11 +1031,11 @@ yelp_status () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_status
0b392c
         exit 1
0b392c
     fi
0b392c
-    check_cache_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+    check_cache_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
     if [ "x$check_site" = "x1" ]; then
0b392c
         yelp-build cache -s -o "$check_cache_file" "$@"
0b392c
     else
0b392c
@@ -1059,7 +1059,7 @@ yelp_validate_db () {
0b392c
     version=$(echo "$docbook_version" | xsltproc - "$1")
0b392c
     major=$(echo "$version" | cut -c1)
0b392c
     if [ "x$major" = "x5" ]; then
0b392c
-        check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+        check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
         rng_uri="http://docbook.org/xml/$version/rng/docbook.rng"
0b392c
         if [ "x$check_jing" = "x1" ]; then
0b392c
             jing -i "$rng_uri" "$1" > "$check_out_file" 2>&1
0b392c
@@ -1067,7 +1067,7 @@ yelp_validate_db () {
0b392c
             xmllint --noout --xinclude --noent --relaxng "$rng_uri" "$1" > "$check_out_file" 2>&1
0b392c
         fi
0b392c
         yelp_check_retval="$?"
0b392c
-        cat "$check_out_file" | grep -v 'validates$'
0b392c
+        grep -v 'validates$' "$check_out_file"
0b392c
         rm "$check_out_file"
0b392c
     elif xmllint --nocdata "$1" | grep -q '
0b392c
         xmllint --noout --xinclude --noent --postvalid "$1" || yelp_check_retval="$?"
0b392c
@@ -1081,10 +1081,10 @@ yelp_validate_page () {
0b392c
     # Using temp files because pipes create subshells, making it really
0b392c
     # hard to return the right exit status in a portable way.
0b392c
     if [ "x$check_rng_dir" = "x" ]; then
0b392c
-        check_rng_dir=`mktemp -d "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
+        check_rng_dir=$(mktemp -d "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
     fi
0b392c
-    check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
0b392c
-    check_rng_file=`(
0b392c
+    check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
0b392c
+    check_rng_file=$( (
0b392c
             echo '
0b392c
             echo ' xmlns:cache="http://projectmallard.org/cache/1.0/"'
0b392c
             echo ' xmlns:xsl="http://www.w3.org/1999/XSL/Transform"'
0b392c
@@ -1104,15 +1104,15 @@ yelp_validate_page () {
0b392c
             echo '</xsl:choose>'
0b392c
             echo '</xsl:template>'
0b392c
             echo '</xsl:stylesheet>'
0b392c
-            ) | xsltproc - "$1"`
0b392c
-    check_rng_file=`urlencode "$check_rng_file" /`.rng
0b392c
+            ) | xsltproc - "$1")
0b392c
+    check_rng_file=$(urlencode "$check_rng_file" /).rng
0b392c
     if [ ! -f "$check_rng_dir/$check_rng_file" ]; then
0b392c
         # If we've already made an RNG file for this version string, don't
0b392c
         # do it again. We've urlencoded the file name + slashes, because
0b392c
         # version strings often contain slashes. But xsltproc treats the
0b392c
         # -o option as a URL and urldecodes, so doubly urlencode, because
0b392c
         # we want the urlencoded string to be the on-disk name.
0b392c
-        xsltproc -o "$check_rng_dir/"`urlencode "$check_rng_file"` \
0b392c
+        xsltproc -o "$check_rng_dir/""$(urlencode "$check_rng_file")" \
0b392c
             --param rng.strict "$check_strict" \
0b392c
             --stringparam rng.strict.allow "$check_strict_allow" \
0b392c
             "$xsl_mal_rng" "$1"
0b392c
@@ -1123,13 +1123,13 @@ yelp_validate_page () {
0b392c
         xmllint --noout --xinclude --noent --relaxng "$check_rng_dir/$check_rng_file" "$1" > "$check_out_file" 2>&1
0b392c
     fi
0b392c
     ret="$?"
0b392c
-    cat "$check_out_file" | grep -v 'validates$'
0b392c
+    grep -v 'validates$' "$check_out_file"
0b392c
     rm "$check_out_file"
0b392c
     return $ret;
0b392c
 }
0b392c
 
0b392c
 yelp_validate () {
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_validate
0b392c
         exit 1
0b392c
     fi
0b392c
@@ -1160,7 +1160,7 @@ yelp_validate () {
0b392c
                 ;;
0b392c
         esac
0b392c
     done
0b392c
-    if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
0b392c
+    if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
0b392c
         yelp_usage_validate
0b392c
         exit 1
0b392c
     fi
0b392c
diff --git a/tools/yelp-new.in b/tools/yelp-new.in
0b392c
index 76bd101..522c3a2 100755
0b392c
--- a/tools/yelp-new.in
0b392c
+++ b/tools/yelp-new.in
0b392c
@@ -19,8 +19,8 @@
0b392c
 tmpldir="@YELP_TMPL_DIR@"
0b392c
 
0b392c
 yelp_describe_tmpl () {
0b392c
-    line="  "`basename "$1" | sed -e 's/\.'$2'$//'`
0b392c
-    desc=`cat "$f" | grep '<\?yelp-tmpl-desc' | sed -e 's/$//'`
0b392c
+    line="  "$(basename "$1" | sed -e 's/\.'"$2"'$//')
0b392c
+    desc=$(grep '<\?yelp-tmpl-desc' "$f" | sed -e 's/$//')
0b392c
     if [ "x$desc" != "x" ]; then
0b392c
         line="$line - $desc"
0b392c
     fi
0b392c
@@ -37,34 +37,50 @@ yelp_usage() {
0b392c
     echo "Options:"
0b392c
     echo "  --stub  Create a .page.stub file instead of a .page file"
0b392c
     echo "  --tmpl  Copy an installed template to a local template"
0b392c
-    if [ -f *.page.tmpl ]; then
0b392c
-        echo ""
0b392c
-        echo "Local Mallard Templates:"
0b392c
-        for f in *.page.tmpl; do
0b392c
+    wroteheader=0
0b392c
+    for f in *.page.tmpl; do
0b392c
+        if [ -e "$f" ]; then
0b392c
+            if [ $wroteheader = 0 ]; then
0b392c
+                echo ""
0b392c
+                echo "Local Mallard Templates:"
0b392c
+                wroteheader=1
0b392c
+            fi
0b392c
             yelp_describe_tmpl "$f" "page.tmpl"
0b392c
-        done
0b392c
-    fi
0b392c
-    if [ -f ${tmpldir}*.page ]; then
0b392c
-        echo ""
0b392c
-        echo "Mallard Templates:"
0b392c
-        for f in ${tmpldir}*.page; do
0b392c
+        fi
0b392c
+    done
0b392c
+    wroteheader=0
0b392c
+    for f in ${tmpldir}*.page; do
0b392c
+        if [ -e "$f" ]; then
0b392c
+            if [ $wroteheader = 0 ]; then
0b392c
+                echo ""
0b392c
+                echo "Mallard Templates:"
0b392c
+                wroteheader=1
0b392c
+            fi
0b392c
             yelp_describe_tmpl "$f" "page"
0b392c
-        done
0b392c
-    fi
0b392c
-    if [ -f *.docbook.tmpl ]; then
0b392c
-        echo ""
0b392c
-        echo "Local DocBook Templates:"
0b392c
-        for f in *.docbook.tmpl; do
0b392c
+        fi
0b392c
+    done
0b392c
+    wroteheader=0
0b392c
+    for f in *.docbook.tmpl; do
0b392c
+        if [ -e "$f" ]; then
0b392c
+            if [ $wroteheader = 0 ]; then
0b392c
+                echo ""
0b392c
+                echo "Local DocBook Templates:"
0b392c
+                wroteheader=1
0b392c
+            fi
0b392c
             yelp_describe_tmpl "$f" "xml.tmpl"
0b392c
-        done
0b392c
-    fi
0b392c
-    if [ -f ${tmpldir}*.docbook ]; then
0b392c
-        echo ""
0b392c
-        echo "DocBook Templates:"
0b392c
-        for f in ${tmpldir}*.docbook; do
0b392c
+        fi
0b392c
+    done
0b392c
+    wroteheader=0
0b392c
+    for f in ${tmpldir}*.docbook; do
0b392c
+        if [ -e "$f" ]; then
0b392c
+            if [ $wroteheader = 0 ]; then
0b392c
+                echo ""
0b392c
+                echo "DocBook Templates:"
0b392c
+                wroteheader=1
0b392c
+            fi
0b392c
             yelp_describe_tmpl "$f" "xml"
0b392c
-        done
0b392c
-    fi
0b392c
+        fi
0b392c
+    done
0b392c
 }
0b392c
 
0b392c
 if [ $# -lt 2 ]; then
0b392c
@@ -91,9 +107,9 @@ while [ $# -gt 0 ]; do
0b392c
 done
0b392c
 
0b392c
 # Locate the template file
0b392c
-if [ $(yelp_get_extension ${1}) = "tmpl" -a -f "${1}" ]; then
0b392c
+if [ "$(yelp_get_extension "${1}")" = "tmpl" ] && [ -f "${1}" ]; then
0b392c
     infile="${1}"
0b392c
-    outext="."$(yelp_get_extension $(basename "${1}" ".tmpl"))
0b392c
+    outext="."$(yelp_get_extension "$(basename "${1}" ".tmpl")")
0b392c
 elif [ -f "${1}.page.tmpl" ]; then
0b392c
     infile="${1}.page.tmpl"
0b392c
     outext=".page"
0b392c
@@ -112,17 +128,17 @@ else
0b392c
 fi
0b392c
 
0b392c
 # Set up some variables for substitution
0b392c
-if type git >/dev/null 2>&1; then
0b392c
-    username=`git config user.name`
0b392c
-    useremail=`git config user.email`
0b392c
+if command -v git >/dev/null 2>&1; then
0b392c
+    username=$(git config user.name)
0b392c
+    useremail=$(git config user.email)
0b392c
 fi
0b392c
-if [ "x$username" = "x" -a "x$useremail" = "x" ]; then
0b392c
-    if type bzr >/dev/null 2>&1; then
0b392c
-        username=`bzr whoami | sed -e 's/ <.*//'`
0b392c
-        useremail=`bzr whoami --email`
0b392c
+if [ "x$username" = "x" ] && [ "x$useremail" = "x" ]; then
0b392c
+    if command -v bzr >/dev/null 2>&1; then
0b392c
+        username=$(bzr whoami | sed -e 's/ <.*//')
0b392c
+        useremail=$(bzr whoami --email)
0b392c
     fi
0b392c
 fi
0b392c
-if [ "x$username" = "x" -a "x$useremail" = "x" ]; then
0b392c
+if [ "x$username" = "x" ] && [ "x$useremail" = "x" ]; then
0b392c
     username='YOUR NAME'
0b392c
     useremail='YOUR EMAIL ADDRESS'
0b392c
 fi
0b392c
@@ -134,14 +150,14 @@ fi
0b392c
 outid=$(basename "${2}")
0b392c
 
0b392c
 if [ "x$spec" != "x" ]; then
0b392c
-    if [ "."$(yelp_get_extension "${2}") = "$spec" ]; then
0b392c
+    if [ ".""$(yelp_get_extension "${2}")" = "$spec" ]; then
0b392c
         outfile="${2}"
0b392c
-    elif [ "."$(yelp_get_extension "${2}") = "$outext" ]; then
0b392c
+    elif [ ".""$(yelp_get_extension "${2}")" = "$outext" ]; then
0b392c
         outfile="${2}${spec}"
0b392c
     else
0b392c
         outfile="${2}${outext}${spec}"
0b392c
     fi
0b392c
-elif [ "."$(yelp_get_extension ${2}) = "$outext" ]; then
0b392c
+elif [ ".""$(yelp_get_extension "${2}")" = "$outext" ]; then
0b392c
     outfile="${2}"
0b392c
 else
0b392c
     outfile="${2}${outext}"
0b392c
@@ -150,10 +166,10 @@ fi
0b392c
 if [ "x$spec" = "x.tmpl" ]; then
0b392c
     cp "$infile" "$outfile"
0b392c
 else
0b392c
-    cat "$infile" | grep -v '<\?yelp-tmpl-desc' | sed \
0b392c
+    grep -v '<\?yelp-tmpl-desc' "$infile" | sed \
0b392c
         -e s/@ID@/"$outid"/ \
0b392c
-        -e s/@DATE@/`date +%Y-%m-%d`/ \
0b392c
-        -e s/@YEAR@/`date +%Y`/ \
0b392c
+        -e s/@DATE@/"$(date +%Y-%m-%d)"/ \
0b392c
+        -e s/@YEAR@/"$(date +%Y)"/ \
0b392c
         -e s/@NAME@/"$username"/ \
0b392c
         -e s/@EMAIL@/"$useremail"/ \
0b392c
         -e s/@TITLE@/"$pagetitle"/ \