Modifications : README - ruse gpg-agent pour les backups
[lhc/ateliers.git] / remote / gpg-gen-key
index fc7ddf7..e13939c 100755 (executable)
@@ -19,7 +19,7 @@ if test ! -e "$tool"/var/sec/openpgp/"$uid".pass.gpg
  fi
 if ! "$tool"/remote/gpg --list-keys -- "$uid" >/dev/null
  then
-       "$tool"/remote/gpg --batch --gen-key
+       "$tool"/remote/gpg --batch --gen-key <<-EOF
                # DOC: http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS;hb=refs/heads/STABLE-BRANCH-1-4
                Key-Type: RSA
                Key-Length: 4096
@@ -30,14 +30,11 @@ if ! "$tool"/remote/gpg --list-keys -- "$uid" >/dev/null
                %commit
                EOF
  fi
-caps=$(
-       "$tool"/remote/gpg --with-colons --fixed-list-mode --with-fingerprint --list-secret-keys \
-        -- "$uid" |
-       sed -e 's/^ssb\(:[^:]*\)\{11\}.*/\1/;t;d'
- )
+caps=$("$tool"/remote/gpg --with-colons --fixed-list-mode --with-fingerprint --list-secret-keys \
+        -- "$uid" | grep '^ssb:' | cut -d : -f 12)
 for cap in ${subkey_caps:-}
  do
-       test ! "$caps" = "$(printf %s "$caps" | sed -e 's/'"$cap"'//g')" ||
+       printf '%s\n' $caps | grep -Fqx "$cap" ||
        printf '%s\n' 8 s e $cap q 4096 ${expire:-0} save |
        "$tool"/remote/gpg --keyid-format "long" --with-colons --fixed-list-mode --expert \
         --passphrase-fd 3 --command-fd 0 --edit-key "$uid" addkey 3<<-EOF