2 # Copyright (C) 2002-2017 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 <https://www.gnu.org/licenses/>.
17 # Various install-sh checks.
19 am_create_testdir
=empty
25 .
/install-sh
${1+"$@"} 2>stderr
&& { cat stderr
>&2; exit 1; }
27 $EGREP "install-sh:.* $err_rx" stderr ||
exit 1
30 get_shell_script install-sh
33 install_sh_fail
'no input file specified'
34 install_sh_fail
'no input file specified' dest
35 install_sh_fail
'no input file specified' -m 644 dest
36 install_sh_fail
'no input file specified' -c -t dest
42 install_sh_fail
'target directory not allowed when installing a directory' \
44 install_sh_fail
'target directory not allowed when installing a directory' \
46 install_sh_fail
'foo: [iI]s not a directory' -t foo bar
47 install_sh_fail
'foo: [iI]s not a directory' bar baz foo
49 install_sh_fail
'target directory not allowed when installing a directory' \
51 install_sh_fail
'target directory not allowed when installing a directory' \
57 for opts
in '-d' '-d -T' '-T -d' '-d -T -d' '-T -d -T -d -T'; do
58 # It should be OK to create no directory. We sometimes need
59 # this when directory are conditionally defined.
64 # Multiple directories (for make installdirs).
65 .
/install-sh
$opts d1 d2 d3 d4
72 .
/install-sh
$opts p
1/p
2/p3 p
4//p
5//p
6//
75 rmdir p
[0-9]/p
[0-9]/p
[0-9]
83 .
/install-sh
-c -m 644 x y
86 .
/install-sh
-m 644 y z
90 .
/install-sh
-m 644 -c x z d1
95 .
/install-sh
-m 644 x z d
2//
100 .
/install-sh
-t d3
-m 644 x z
105 .
/install-sh
-t d
4// -m 644 x z
110 .
/install-sh
-T x d
3/y
113 install_sh_fail
'd3: [iI]s a directory' -T x d3
114 install_sh_fail
'd4(//)?: [iI]s a directory' -T x d
4//
116 # Ensure that install-sh works with names that include spaces.
119 .
/install-sh
'a b' 'x y'
120 test -f x\ \ y
/a\ \ b
123 # Ensure we do not run into 'test' operator precedence bugs with Tru64 sh.
124 for c
in = '(' ')' '!'; do
125 install_sh_fail
'no input file specified' $c
126 test -f stderr
# sanity check
127 grep 'test: ' stderr
&& exit 1
128 # Skip tests if the file system is not capable.
129 mkdir .
/$c ||
continue
131 .
/install-sh
-d $c/$c/$c
133 .
/install-sh
-d $c d
5/$c/$c
142 ( : > .
/$c ) ||
continue
143 .
/install-sh
$c x d
5/$c/$c
147 .
/install-sh
-t d
5/$c/$c $c x