2 # Copyright (C) 2011 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Test how the `missing' script wraps the`tar' program.
21 get_shell_script
"missing"
23 old_PATH
=$PATH; export old_PATH
24 new_PATH
=`pwd`/bin
$PATH_SEPARATOR$PATH
27 cat > data.txt
<<'END'
28 To be, or not to be: that is the question:
29 Whether 'tis nobler in the mind to suffer
33 cat > nonesuch
<<'END'
40 for nullify_gnu
in yes no
; do
44 cp nonesuch bin
/gnutar
45 PATH
=$new_PATH; export PATH
;
54 Exit
99 # Can't happen.
57 cp ..
/data.txt foobar.txt
58 ..
/missing
--run tar cvf mu.
tar foobar.txt
61 ..
/missing
--run tar tf mu.
tar >output
2>&1 ||
{ cat output
; Exit
1; }
63 $FGREP 'foobar.txt' output
65 ..
/missing
--run tar xvf mu.
tar
66 diff ..
/data.txt foobar.txt
67 PATH
=$old_PATH; export PATH
;
73 # Helper scripts and functions for next tests.
75 cat > fake-gnu-tar
<<'END'
77 case " $* " in *\ --version\ *) echo fake GNU tar; exit $?;; esac
78 PATH=$old_PATH; export PATH
81 chmod a
+x fake-gnu-tar
83 cat > failing-tar
<<'END'
85 echo "Error message from tar passed through" >&2
92 grep "WARNING:.* can't.* run \`tar' with .*given arguments" $
*
95 # The `tar' program does not work with the given options, but we have
97 cp failing-tar bin
/tar
99 case $pfx in g
) othpfx
=gnu
;; gnu
) othpfx
=g
;; *) Exit
99;; esac
100 cp nonesuch bin
/${othpfx}tar
101 if ${pfx}tar --version |
grep GNU
; then :; else
102 cp fake-gnu-tar bin
/${pfx}tar
105 PATH
=$new_PATH; export PATH
106 .
/missing
--run tar cvf
$tarball .
/data.txt
2>stderr \
107 ||
{ cat stderr
>&2; Exit
1; }
109 PATH
=$old_PATH; export PATH
111 grep_tar_failed stderr
112 grep "Error message from tar passed through" stderr
113 grep "[Tt]rying to use GNU tar.*${pfx}tar" stderr
114 grep "${othpfx}tar" stderr
&& Exit
1
115 : # For shells with broken 'set -e'
120 # The `tar' program does not work with the given options, and we don't
121 # have neither gtar nor gnutar.
122 cp failing-tar bin
/tar
124 cp nonesuch bin
/gnutar
125 PATH
=$new_PATH; export PATH
126 .
/missing
--run tar cvf foo.
tar .
/data.txt
2>stderr \
127 && { cat stderr
>&2; Exit
1; }
129 PATH
=$old_PATH; export PATH
131 grep_tar_failed stderr
132 grep "Error message from tar passed through" stderr
133 grep "[iI]nstall GNU tar or Free [pP]axutils" stderr
134 $EGREP "(g|gnu)tar" stderr
&& Exit
1
138 # We try to use an option that causes any `tar' program (GNU or non-GNU) to.
139 .
/missing
--run tar --bad-unknonw-option cvf foo.
tar .
/data.txt
2>stderr \
140 && { cat stderr
>&2; Exit
1; }
143 grep_tar_failed stderr
144 grep "bad-unknonw-option" stderr
145 for p
in gtar gnutar
; do
146 if $p --version; then
151 test `$EGREP -c "[Tt]rying to use GNU tar.*$p" stderr` -eq $cnt