Hello,

This is my first diff I've submitted here, so I imagine there's a dozen things I'm missing/clueless about.

I've been making an effort to start browsing the tree and reading the code regularly. I came across this file, I know it's a regress test, so there may be some context/history I'm ignorant to.

All I know is, is that it is cleaner to use '[:space:]' rather than ' \n' unless you are intentionally ignoring tabs and '\r' etc. I also know that '[[:alpha:]] is a lot cleaner than [a-zA-Z] and could also avoid potential issues with localization (I'm not an expert on that, just what I was told).

I know OpenSSH portable runs on some wacky systems that may not support character classes, but if this test is just for OpenBSD then all should be well.


Index: regress/usr.bin/ssh/unittests/sshkey/mktestdata.sh
===================================================================
RCS file: /cvs/src/regress/usr.bin/ssh/unittests/sshkey/mktestdata.sh,v
retrieving revision 1.11
diff -u -p -u -r1.11 mktestdata.sh
--- regress/usr.bin/ssh/unittests/sshkey/mktestdata.sh  19 Jun 2020 03:48:49 -0000      1.11 +++ regress/usr.bin/ssh/unittests/sshkey/mktestdata.sh  14 Jul 2020 07:48:40 -0000
@@ -9,13 +9,13 @@ rsa_params() {
        set -e
        openssl rsa -noout -text -in $_in | \
            awk '/^modulus:$/,/^publicExponent:/' | \
-           grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.n
+           grep -v '^[[:alpha:]]' | tr -d '[:space:]:' > ${_outbase}.n
        openssl rsa -noout -text -in $_in | \
            awk '/^prime1:$/,/^prime2:/' | \
-           grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.p
+           grep -v '^[[:alpha:]]' | tr -d '[:space:]:' > ${_outbase}.p
        openssl rsa -noout -text -in $_in | \
            awk '/^prime2:$/,/^exponent1:/' | \
-           grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.q
+           grep -v '^[[:alpha:]]' | tr -d '[:space:]:' > ${_outbase}.q
        for x in n p q ; do
                echo "" >> ${_outbase}.$x
                echo ============ ${_outbase}.$x
@@ -30,13 +30,13 @@ dsa_params() {
        set -e
        openssl dsa -noout -text -in $_in | \
            awk '/^priv:$/,/^pub:/' | \
-           grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.priv
+           grep -v '^[[alpha:]]' | tr -d '[:space:]:' > ${_outbase}.priv
        openssl dsa -noout -text -in $_in | \
            awk '/^pub:/,/^P:/' | #\
-           grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.pub
+           grep -v '^[[:alpha:]]' | tr -d '[:space:]:' > ${_outbase}.pub
        openssl dsa -noout -text -in $_in | \
            awk '/^G:/,0' | \
-           grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.g
+           grep -v '^[[:alpha:]]' | tr -d '[:space:]:' > ${_outbase}.g
        for x in priv pub g ; do
                echo "" >> ${_outbase}.$x
                echo ============ ${_outbase}.$x
@@ -51,10 +51,10 @@ ecdsa_params() {
        set -e
        openssl ec -noout -text -in $_in | \
            awk '/^priv:$/,/^pub:/' | \
-           grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.priv
+           grep -v '^[[:alpha:]]' | tr -d '[:space:]:' > ${_outbase}.priv
        openssl ec -noout -text -in $_in | \
            grep "ASN1 OID:" | \
            sed 's/.*: //;s/ *$//' | tr -d '\n' > ${_outbase}.curve


Reply via email to