1 | #!/bin/sh
|
---|
2 | # Test -z/--null-data option
|
---|
3 |
|
---|
4 | # Copyright (C) 2016-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 | # Two lines, differ based on the EOL character.
|
---|
22 | printf "AB\000CD\nEF\n\000" > in1 || framework_failure_
|
---|
23 |
|
---|
24 | # 's/^./x/' cmd processed with EOF=\n
|
---|
25 | printf "xB\000CD\nxF\nx" > exp-s-nl || framework_failure_
|
---|
26 | # 's/^./x/' cmd processed with EOF=\0
|
---|
27 | printf "xB\000xD\nEF\n\000" > exp-s-z || framework_failure_
|
---|
28 |
|
---|
29 | # '=' cmd processed with EOF=\n
|
---|
30 | printf "1\nAB\000CD\n2\nEF\n3\n\000" > exp-=-nl || framework_failure_
|
---|
31 |
|
---|
32 | # '=' cmd processed with EOF=\0
|
---|
33 | printf "1\000AB\0002\000CD\nEF\n\000" > exp-=-z || framework_failure_
|
---|
34 |
|
---|
35 |
|
---|
36 | # 'l' cmd processed with EOF=\n
|
---|
37 | cat <<\EOF >exp-l-nl || framework_failure_
|
---|
38 | AB\000CD$
|
---|
39 | EF$
|
---|
40 | \000$
|
---|
41 | EOF
|
---|
42 |
|
---|
43 | # 'l' cmd processed with EOF=\0
|
---|
44 | printf 'AB$\000CD\\nEF\\n$\000' >exp-l-z || framework_failure_
|
---|
45 |
|
---|
46 | # 'F' cmd with EOL=\n
|
---|
47 | printf "in1\n" > exp-F-nl || framework_failure_
|
---|
48 |
|
---|
49 | # 'F' cmd with EOL=\0
|
---|
50 | printf "in1\000" > exp-F-z || framework_failure_
|
---|
51 |
|
---|
52 |
|
---|
53 | # Test substitution
|
---|
54 | sed 's/^./x/' in1 > out-s-nl || fail=1
|
---|
55 | compare_ exp-s-nl out-s-nl || fail=1
|
---|
56 |
|
---|
57 | sed -z 's/^./x/' in1 > out-s-z || fail=1
|
---|
58 | compare_ exp-s-z out-s-z || fail=1
|
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|
62 | # Test '=' command
|
---|
63 | sed = in1 > out-=-nl || fail=1
|
---|
64 | compare_ exp-=-nl out-=-nl || fail=1
|
---|
65 |
|
---|
66 | sed -z = in1 > out-=-z || fail=1
|
---|
67 | compare_ exp-=-z out-=-z || fail=1
|
---|
68 |
|
---|
69 |
|
---|
70 |
|
---|
71 | # Test 'l' command
|
---|
72 | sed -n l in1 > out-l-nl || fail=1
|
---|
73 | compare_ exp-l-nl out-l-nl || fail=1
|
---|
74 |
|
---|
75 | sed -zn l in1 > out-l-z || fail=1
|
---|
76 | compare_ exp-l-z out-l-z || fail=1
|
---|
77 |
|
---|
78 |
|
---|
79 | # Test 'F' command
|
---|
80 | sed -n 1F in1 > out-F-nl || fail=1
|
---|
81 | compare_ exp-F-nl out-F-nl || fail=1
|
---|
82 |
|
---|
83 | sed -zn 1F in1 > out-F-z || fail=1
|
---|
84 | compare_ exp-F-z out-F-z || fail=1
|
---|
85 |
|
---|
86 |
|
---|
87 | Exit $fail
|
---|