WinGit(Inno): Rename shell extension to "Git Bash Here"
[msysgit/mtrensch.git] / mingw / bin / gpg-zip
blob07cd4741a960966e9f48abbe18f691eb63e1d632
1 #!/bin/sh
3 # gpg-archive - gpg-ized tar using the same format as PGP's PGP Zip.
4 # Copyright (C) 2005 Free Software Foundation, Inc.
6 # This file is part of GnuPG.
8 # GnuPG is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # GnuPG is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 # Despite the name, PGP Zip format is actually an OpenPGP-wrapped tar
23 # file. To be compatible with PGP itself, this must be a USTAR format
24 # tar file. Unclear on whether there is a distinction here between
25 # the GNU or POSIX variant of USTAR.
27 VERSION=1.4.7
28 TAR=/bin/tar
29 GPG=gpg
31 usage="\
32 Usage: gpg-zip [--help] [--version] [--encrypt] [--decrypt] [--symmetric]
33 [--list-archive] [--output FILE] [--gpg GPG] [--gpg-args ARGS]
34 [--tar TAR] [--tar-args ARGS] filename1 [filename2, ...]
35 directory1 [directory2, ...]
37 Encrypt or sign files into an archive."
39 while test $# -gt 0 ; do
40 case $1 in
41 -h | --help | --h*)
42 echo "$usage"
43 exit 0
45 --list-archive)
46 list=yes
47 create=no
48 unpack=no
49 shift
51 --encrypt | -e)
52 gpg_args="$gpg_args --encrypt"
53 list=no
54 create=yes
55 unpack=no
56 shift
58 --decrypt | -d)
59 gpg_args="$gpg_args --decrypt"
60 list=no
61 create=no
62 unpack=yes
63 shift
65 --symmetric | -c)
66 gpg_args="$gpg_args --symmetric"
67 list=no
68 create=yes
69 unpack=no
70 shift
72 --sign | -s)
73 gpg_args="$gpg_args --sign"
74 list=no
75 create=yes
76 unpack=no
77 shift
79 --recipient | -r)
80 gpg_args="$gpg_args --recipient $2"
81 shift
82 shift
84 --local-user | -u)
85 gpg_args="$gpg_args --local-user $2"
86 shift
87 shift
89 --output | -o)
90 gpg_args="$gpg_args --output $2"
91 shift
92 shift
94 --version)
95 echo "gpg-zip (GnuPG) $VERSION"
96 exit 0
98 --gpg)
99 GPG=$1
100 shift
102 --gpg-args)
103 gpg_args="$gpg_args $2"
104 shift
105 shift
107 --tar)
108 TAR=$1
109 shift
111 --tar-args)
112 tar_args="$tar_args $2"
113 shift
114 shift
117 shift
118 break
121 echo "$usage" 1>&2
122 exit 1
125 break
127 esac
128 done
130 if test x$create = xyes ; then
131 # echo "$TAR -cf - "$@" | $GPG --set-filename x.tar $gpg_args" 1>&2
132 $TAR -cf - "$@" | $GPG --set-filename x.tar $gpg_args
133 elif test x$list = xyes ; then
134 # echo "cat \"$1\" | $GPG $gpg_args | $TAR $tar_args -tf -" 1>&2
135 cat "$1" | $GPG $gpg_args | $TAR $tar_args -tf -
136 elif test x$unpack = xyes ; then
137 # echo "cat \"$1\" | $GPG $gpg_args | $TAR $tar_args -xvf -" 1>&2
138 cat "$1" | $GPG $gpg_args | $TAR $tar_args -xvf -
139 else
140 echo "$usage" 1>&2
141 exit 1