4 # Copyright (C) 2003, 2006-2009 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 if test "$VERBOSE" = yes; then
27 nohup sh -c 'echo stdout; echo stderr 1>&2' 2>err || fail=1
29 # Be careful. The results of the above nohup command
30 # change depending on whether stdin and stdout are redirected.
32 test "`cat nohup.out`" = stdout || fail=1
34 echo 'nohup: ignoring input and appending output to `nohup.out'\'
36 echo 'nohup: appending output to `nohup.out'\'
39 # Here it should not even exist.
40 test -f nohup.out && fail=1
42 echo 'nohup: ignoring input' >exp
47 echo 'stderr' >> exp || fail=1
49 compare exp err || fail=1
50 rm -f nohup.out err exp
51 # ----------------------
53 # Be careful. The results of the following nohup command
54 # change depending on whether stderr is redirected.
55 nohup sh -c 'echo stdout; echo stderr 1>&2' >out || fail=1
57 test "`cat out|tr '\n' -`" = stdout-stderr- || fail=1
59 test "`cat out|tr '\n' -`" = stdout- || fail=1
61 # It must *not* exist.
62 test -f nohup.out && fail=1
64 # ----------------------
66 # Bug present through coreutils 8.0: failure to print advisory message
67 # to stderr must be fatal. Requires stdout to be terminal.
68 if test -w /dev/full && test -c /dev/full; then
72 nohup echo hi 2> /dev/full
73 test $? = 125 || fail=1
74 test -f nohup.out || fail=1
75 test -s nohup.out && fail=1
81 nohup no-such-command 2> err
84 test $errno = 127 || fail=1
86 test -f nohup.out || fail=1
88 test -s nohup.out && fail=1
91 cat <<\EOF > exp || fail=1
92 nohup: appending output to `nohup.out'
93 nohup: cannot run command `no-such-command': No such file or directory
95 # Disable these comparisons. Too much variation in 2nd line.
96 # compare exp err || fail=1
97 rm -f nohup.out err exp
98 # ----------------------
103 test $errno = 126 || fail=1
106 test -f nohup.out || fail=1
108 test -s nohup.out && fail=1
111 cat <<\EOF > exp || fail=1
112 nohup: appending output to `nohup.out'
113 nohup: cannot run command `./k': Permission denied
115 # Disable these comparisons. Too much variation in 2nd line.
116 # compare exp err || fail=1
118 # Make sure it fails with exit status of 125 when given too few arguments,
119 # except that POSIX requires 127 in this case.
120 nohup >/dev/null 2>&1
121 test $? = 125 || fail=1
122 POSIXLY_CORRECT=1 nohup >/dev/null 2>&1
123 test $? = 127 || fail=1