Fixing ssl-cert-{sha512,sha256,sha1,md5}()
authorFrank Terbeck <ft@grml.org>
Thu, 20 Jan 2011 08:30:29 +0000 (09:30 +0100)
committerFrank Terbeck <ft@grml.org>
Thu, 20 Jan 2011 08:30:29 +0000 (09:30 +0100)
These functions are generated in a loop. However, the way they were
generated was broken. The loop variable is *not* replaced by a literal
string in the resulting functions. Therefore, as soon as the variable
is unset all functions become broken. Luckily, they broke loudly.
Otherwise this may not have been caught easily.

Reported-by: Michael Gebetsroither <gebi@grml.org>
Signed-off-by: Frank Terbeck <ft@grml.org>
etc/zsh/zshrc

index decda2b..0b82cb3 100644 (file)
@@ -3079,14 +3079,14 @@ exit 0;
 ssl_hashes=( sha512 sha256 sha1 md5 )
 
 for sh in ${ssl_hashes}; do
-    ssl-cert-${sh}() {
+    eval 'ssl-cert-'${sh}'() {
         emulate -L zsh
         if [[ -z $1 ]] ; then
-            printf 'usage: %s <file>\n' "ssh-cert-${sh}"
+            printf '\''usage: %s <file>\n'\'' "ssh-cert-'${sh}'"
             return 1
         fi
-        openssl x509 -noout -fingerprint -${sh} -in $1
-    }
+        openssl x509 -noout -fingerprint -'${sh}' -in $1
+    }'
 done; unset sh
 
 ssl-cert-fingerprints() {