[gnutls-devel] [PATCH 2/4] tests: key-tests: cleanup shell usage

Alon Bar-Lev alon.barlev at gmail.com
Thu Jun 18 08:41:53 CEST 2015


Add quotes for most usages of variables.

Added ${} for variables.

Signed-off-by: Alon Bar-Lev <alon.barlev at gmail.com>
---
 tests/key-tests/key-id | 14 ++++-----
 tests/key-tests/pkcs8  | 84 +++++++++++++++++++++++++-------------------------
 2 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/tests/key-tests/key-id b/tests/key-tests/key-id
index 9bad211..7e09617 100755
--- a/tests/key-tests/key-id
+++ b/tests/key-tests/key-id
@@ -22,23 +22,23 @@
 
 set -e
 
-srcdir=${srcdir:-.}
-CERTTOOL=${CERTTOOL:-../../src/certtool$EXEEXT}
+srcdir="${srcdir:-.}"
+CERTTOOL="${CERTTOOL:-../../src/certtool$EXEEXT}"
 
-PARAMS="--generate-certificate --load-privkey $srcdir/key-user.pem --load-ca-privkey $srcdir/key-ca.pem --template tmpl"
+PARAMS="--generate-certificate --load-privkey '${srcdir}/key-user.pem' --load-ca-privkey '${srcdir}/key-ca.pem' --template tmpl"
 
 echo "serial = 0" > tmpl
 
-#$CERTTOOL $PARAMS --load-ca-certificate $srcdir/ca-gnutls-keyid.pem \
+#eval "${CERTTOOL}" ${PARAMS} --load-ca-certificate $srcdir/ca-gnutls-keyid.pem \
 #    --outfile user-gnutls-keyid.pem 2> /dev/null
 
-#$CERTTOOL $PARAMS --load-ca-certificate $srcdir/ca-no-keyid.pem \
+#eval "${CERTTOOL}" ${PARAMS} --load-ca-certificate $srcdir/ca-no-keyid.pem \
 #    --outfile user-no-keyid.pem 2> /dev/null
 
-$CERTTOOL $PARAMS --load-ca-certificate $srcdir/ca-weird-keyid.pem \
+eval "${CERTTOOL}" ${PARAMS} --load-ca-certificate "${srcdir}/ca-weird-keyid.pem" \
     --outfile user-weird-keyid.pem 2> /dev/null
 
-if $CERTTOOL -i < user-weird-keyid.pem \
+if "${CERTTOOL}" -i < user-weird-keyid.pem \
     | grep '7a2c7a6097460603cbfb28e8e219df18deeb4e0d' > /dev/null; then
     :
 else
diff --git a/tests/key-tests/pkcs8 b/tests/key-tests/pkcs8
index 746bd98..8ea8dc9 100755
--- a/tests/key-tests/pkcs8
+++ b/tests/key-tests/pkcs8
@@ -18,118 +18,118 @@
 # along with GnuTLS; if not, write to the Free Software Foundation,
 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-srcdir=${srcdir:-.}
-CERTTOOL=${CERTTOOL:-../../src/certtool$EXEEXT}
-GREP=${GREP:-grep}
+srcdir="${srcdir:-.}"
+CERTTOOL="${CERTTOOL:-../../src/certtool$EXEEXT}"
+GREP="${GREP:-grep}"
 
 # check keys with password
-$CERTTOOL --to-p8 --load-privkey  $srcdir/key-ca.pem --password "1234" \
+"${CERTTOOL}" --to-p8 --load-privkey  "${srcdir}/key-ca.pem" --password "1234" \
     --outfile tmp-key-ca.p8 2>/dev/null
 
-$GREP "BEGIN ENCRYPTED PRIVATE KEY" tmp-key-ca.p8  >/dev/null 2>&1
+${GREP} "BEGIN ENCRYPTED PRIVATE KEY" tmp-key-ca.p8  >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in converting key to PKCS #8 with password"
-  exit $rc
+  exit ${rc}
 fi
 
-$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca.pem --password "1234" >/dev/null 2>&1
+"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca.pem" --password "1234" >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in reading PKCS #8 key with password"
-  exit $rc
+  exit ${rc}
 fi
 
-$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca-1234.p8 --password "1234" >/dev/null 2>&1
+"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca-1234.p8" --password "1234" >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in reading saved PKCS #8 key with password"
-  exit $rc
+  exit ${rc}
 fi
 
 #keys encrypted with empty password
-$CERTTOOL --to-p8 --load-privkey  $srcdir/key-ca.pem --password "" \
+"${CERTTOOL}" --to-p8 --load-privkey  "${srcdir}/key-ca.pem" --password "" \
     --outfile tmp-key-ca.p8 2>/dev/null
 
-$GREP "BEGIN PRIVATE KEY" tmp-key-ca.p8  >/dev/null 2>&1
+${GREP} "BEGIN PRIVATE KEY" tmp-key-ca.p8  >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in converting key to PKCS #8 with empty password"
-  exit $rc
+  exit ${rc}
 fi
 
-$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca.pem --password "" >/dev/null 2>&1
+"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca.pem" --password "" >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in reading PKCS #8 key with empty password"
-  exit $rc
+  exit ${rc}
 fi
 
-$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca-empty.p8 --password "" >/dev/null 2>&1
+"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca-empty.p8" --password "" >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in reading saved PKCS #8 key with empty password"
-  exit $rc
+  exit ${rc}
 fi
 
 #keys encrypted with null password
-$CERTTOOL --to-p8 --load-privkey  $srcdir/key-ca.pem --null-password \
+"${CERTTOOL}" --to-p8 --load-privkey  "${srcdir}/key-ca.pem" --null-password \
     --outfile tmp-key-ca.p8 2>/dev/null
 
-$GREP "BEGIN ENCRYPTED PRIVATE KEY" tmp-key-ca.p8 >/dev/null 2>&1
+${GREP} "BEGIN ENCRYPTED PRIVATE KEY" tmp-key-ca.p8 >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in converting key to PKCS #8 with null password"
-  exit $rc
+  exit ${rc}
 fi
 
-$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca.pem --null-password >/dev/null 2>&1
+"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca.pem" --null-password >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in reading PKCS #8 key with null password"
-  exit $rc
+  exit ${rc}
 fi
 
-$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca-null.p8 --null-password >/dev/null 2>&1
+"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca-null.p8" --null-password >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in reading saved PKCS #8 key with null password"
-  exit $rc
+  exit ${rc}
 fi
 
 # Tests for PKCS #8 ECC keys
 
-$CERTTOOL -k --infile $srcdir/key-ecc.pem >/dev/null 2>&1
+"${CERTTOOL}" -k --infile "${srcdir}/key-ecc.pem" >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in reading saved ECC key"
-  exit $rc
+  exit ${rc}
 fi
 
-$CERTTOOL -k --pkcs8 --infile $srcdir/key-ecc.p8 >/dev/null 2>&1
+"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ecc.p8" >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in reading saved PKCS #8 ECC key"
-  exit $rc
+  exit ${rc}
 fi
 
-$CERTTOOL -k --pkcs8 --infile $srcdir/openssl-key-ecc.p8 >/dev/null 2>&1
+"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/openssl-key-ecc.p8" >/dev/null 2>&1
 rc=$?
 # We're done.
-if test "$rc" != "0"; then
+if test "${rc}" != "0"; then
   echo "Error in reading saved openssl PKCS #8 ECC key"
-  exit $rc
+  exit ${rc}
 fi
 
 rm -f tmp-key-ca.p8
-- 
2.3.6




More information about the Gnutls-devel mailing list