1 | #!/bin/sh
|
---|
2 | # Test 'l' command with different widths
|
---|
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 | # 10 20 30 40 50 60 70 75
|
---|
22 | cat <<\EOF >in1 || framework_failure_
|
---|
23 | 0123456789012345678901234567890123456789012345678901234567890123456789012345
|
---|
24 | EOF
|
---|
25 |
|
---|
26 | # default: 70 characters (including the \n)
|
---|
27 | cat <<\EOF >exp-def || framework_failure_
|
---|
28 | 012345678901234567890123456789012345678901234567890123456789012345678\
|
---|
29 | 9012345$
|
---|
30 | EOF
|
---|
31 |
|
---|
32 | # 11 characters
|
---|
33 | cat <<\EOF >exp-11 || framework_failure_
|
---|
34 | 0123456789\
|
---|
35 | 0123456789\
|
---|
36 | 0123456789\
|
---|
37 | 0123456789\
|
---|
38 | 0123456789\
|
---|
39 | 0123456789\
|
---|
40 | 0123456789\
|
---|
41 | 012345$
|
---|
42 | EOF
|
---|
43 |
|
---|
44 | # command 'l n' is a gnu extension, rejected in posix mode
|
---|
45 | cat <<\EOF >exp-err-posix-ln || framework_failure_
|
---|
46 | sed: -e expression #1, char 2: extra characters after command
|
---|
47 | EOF
|
---|
48 |
|
---|
49 | # sed's default: 70 characters
|
---|
50 | sed -n l in1 >out-def || fail=1
|
---|
51 | compare_ exp-def out-def || fail=1
|
---|
52 |
|
---|
53 | # limit with COLS envvar, sed subtracts one to avoid ttys linewraps
|
---|
54 | COLS=12 sed -n l in1 >out-cols12 || fail=1
|
---|
55 | compare_ exp-11 out-cols12 || fail=1
|
---|
56 |
|
---|
57 | # invalid COLS envvar should be ignored (wrap at default=70)
|
---|
58 | COLS=0 sed -n l in1 >out-cols0 || fail=1
|
---|
59 | compare_ exp-def out-cols0 || fail=1
|
---|
60 | COLS=foo sed -n l in1 >out-cols-foo || fail=1
|
---|
61 | compare_ exp-def out-cols-foo || fail=1
|
---|
62 |
|
---|
63 | # limit with -l parameter
|
---|
64 | sed -l 11 -n l in1 >out-l11 || fail=1
|
---|
65 | compare_ exp-11 out-l11 || fail=1
|
---|
66 |
|
---|
67 | # limit with 'ln' command (gnu extension)
|
---|
68 | sed -n l11 in1 >out-ln-11 || fail=1
|
---|
69 | compare_ exp-11 out-ln-11 || fail=1
|
---|
70 |
|
---|
71 | # limit with 'ln' command (gnu extension)
|
---|
72 | returns_ 1 sed --posix -n l11 in1 2>err-posix-ln || fail=1
|
---|
73 | compare_ exp-err-posix-ln err-posix-ln || fail=1
|
---|
74 |
|
---|
75 | Exit $fail
|
---|