doc: stat: clarify that %t and %T expand to the file system type
[coreutils/ericb.git] / tests / tail-2 / F-vs-rename
blob5b4223e2bd6266dd2216210955431d1ace5cc00b
1 #!/bin/sh
2 # demonstrate that tail -F works when renaming the tailed files
3 # Before coreutils-8.3, tail -F a b would stop tracking additions to b
4 # after "mv a b".
6 # Copyright (C) 2009-2011 Free Software Foundation, Inc.
8 # This program 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 3 of the License, or
11 # (at your option) any later version.
13 # This program 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, see <http://www.gnu.org/licenses/>.
21 . "${srcdir=.}/init.sh"; path_prepend_ ../src
22 print_ver_ tail
24 touch a b || framework_failure_
26 debug='---disable-inotify'
27 debug=
28 tail $debug -F -s.1 a b > out 2>&1 & pid=$!
30 check_tail_output()
32 local delay="$1"
33 grep "$tail_re" out > /dev/null ||
34 { sleep $delay; return 1; }
37 # Wait up to 6.3s for tail to start
38 echo x > a
39 tail_re='^x$' retry_delay_ check_tail_output .1 7 || fail=1
41 mv a b || fail=1
43 # Wait 6.3s for this diagnostic:
44 # tail: `a' has become inaccessible: No such file or directory
45 tail_re='inaccessible' retry_delay_ check_tail_output .1 7 || fail=1
47 echo x > a
48 # Wait up to 6.3s for this to appear in the output:
49 # "tail: `...' has appeared; following end of new file"
50 tail_re='has appeared' retry_delay_ check_tail_output .1 7 ||
51 { echo "$0: a: unexpected delay?"; cat out; fail=1; }
53 echo y >> b
54 # Wait up to 6.3s for "y" to appear in the output:
55 tail_f_vs_rename_2() {
56 local delay="$1"
57 tr '\n' @ < out | grep '@@==> b <==@y@$' > /dev/null ||
58 { sleep $delay; return 1; }
60 retry_delay_ tail_f_vs_rename_2 .1 7 ||
61 { echo "$0: b: unexpected delay?"; cat out; fail=1; }
63 echo z >> a
64 # Wait up to 6.3s for "z" to appear in the output:
65 tail_f_vs_rename_3() {
66 local delay="$1"
67 tr '\n' @ < out | grep '@@==> a <==@z@$' > /dev/null ||
68 { sleep $delay; return 1; }
70 retry_delay_ tail_f_vs_rename_3 .1 7 ||
71 { echo "$0: a: unexpected delay?"; cat out; fail=1; }
73 kill -HUP $pid
75 Exit $fail