Providing shell-completions for gpg, minor scripting issues

Axel Liljencrantz liljencrantz at
Fri Jan 13 15:34:08 CET 2006


I'm currently writing a set of gpg-specific completions for the fish
shell ( These completions already feature
all the switches for gpg, and a description of each switch, usually
the first sentence of the manpage description.

While doing this, I've run across an issue with scripting. Fish allows
you to tab-complete sub-arguments to switches, so you can for instance

fish> gpg --verify-options=show-photos,show-us<TAB>

and the line will complete to

fish> gpg --verify-options=show-photos,show-user-notations

I'd like to do this for the various switches that accept a crypto
algorithm, unfortunatly I have some problems with getting a good
listing of the algorithms supported by the users GPG implementation.
Running 'gpg --version' prints them, but it does so in format that I'm
not very happy with:

gpg (GnuPG) 1.4.1
Copyright (C) 2005 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.

Home: ~/.gnupg
Stödda algoritmer:
öppen nyckel: RSA, RSA-E, RSA-S, ELG-E, DSA
Kontrollsumma: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512
Komprimering: Okomprimerad, ZIP, ZLIB, BZIP2

As you can see, the format is locale dependant. I'm also worried that
changed phrasing, further algorithm subdivision, etc. will mean that
my parsing rules will break. To get a locale independant format, I
have to invoke GPG with a LC_ALL set to C. This doen't seem very
optimal to me. Is there some other way of getting this information
that I've missed? If not, could perhaps the --with-colons switch be
made to act on --version as well, to get an more robust format?


More information about the Gnupg-users mailing list