1 | #!/bin/sh
|
---|
2 | # Test '0rFILE' command
|
---|
3 |
|
---|
4 | # Copyright (C) 2021-2022 Free Software Foundation, Inc.
|
---|
5 |
|
---|
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.
|
---|
10 |
|
---|
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.
|
---|
15 |
|
---|
16 | # You should have received a copy of the GNU General Public License
|
---|
17 | # along with this program. If not, see <https://www.gnu.org/licenses/>.
|
---|
18 | . "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed
|
---|
19 | print_ver_ sed
|
---|
20 |
|
---|
21 | cat <<\EOF >in1 || framework_failure_
|
---|
22 | HELLO
|
---|
23 | WORLD
|
---|
24 | EOF
|
---|
25 |
|
---|
26 | cat <<\EOF >in2 || framework_failure_
|
---|
27 | 1
|
---|
28 | 2
|
---|
29 | 3
|
---|
30 | EOF
|
---|
31 |
|
---|
32 | cat <<\EOF >exp1 || framework_failure_
|
---|
33 | HELLO
|
---|
34 | WORLD
|
---|
35 | 1
|
---|
36 | 2
|
---|
37 | 3
|
---|
38 | EOF
|
---|
39 |
|
---|
40 | cat <<\EOF >exp2 || framework_failure_
|
---|
41 | 1
|
---|
42 | HELLO
|
---|
43 | WORLD
|
---|
44 | 2
|
---|
45 | HELLO
|
---|
46 | WORLD
|
---|
47 | 3
|
---|
48 | EOF
|
---|
49 |
|
---|
50 | cat <<\EOF> exp-err-addr0 || framework_failure_
|
---|
51 | sed: -e expression #1, char 4: invalid usage of line address 0
|
---|
52 | EOF
|
---|
53 |
|
---|
54 | # Typical usage
|
---|
55 | sed '0rin1' in2 >out1 || fail=1
|
---|
56 | compare_ exp1 out1 || fail=1
|
---|
57 |
|
---|
58 | # Ensure no regression for '0,/REGEXP/r'
|
---|
59 | sed '0,/2/rin1' in2 >out2 || fail=1
|
---|
60 | compare_ exp2 out2 || fail=1
|
---|
61 |
|
---|
62 | # Ensure '0r' doesn't accept a numeric address range
|
---|
63 | returns_ 1 sed '0,4rin1' in2 2>err3 || fail=1
|
---|
64 | compare_ exp-err-addr0 err3 || fail=1
|
---|
65 |
|
---|
66 | # Test with -i
|
---|
67 | sed -i '0rin1' in2 || fail=1
|
---|
68 | compare_ exp1 in2 || fail=1
|
---|
69 |
|
---|
70 | Exit $fail
|
---|