| 1 | #!/bin/sh
|
|---|
| 2 | # Test 'R' command
|
|---|
| 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 | printf "%s\n" x y > a || framework_failure_
|
|---|
| 22 | printf "%s\n" 1 2 > b || framework_failure_
|
|---|
| 23 | printf "%s\n" X > c || framework_failure_
|
|---|
| 24 | touch d || framework_failure_
|
|---|
| 25 |
|
|---|
| 26 | # Read and interleave two lines
|
|---|
| 27 | printf "%s\n" x 1 y 2 > exp1 || framework_failure_
|
|---|
| 28 | sed -e 1Rb -e 2Rb a > out1 || fail=1
|
|---|
| 29 | compare_ exp1 out1 || fail=1
|
|---|
| 30 |
|
|---|
| 31 | # Read a non-existing file, silently ignored
|
|---|
| 32 | sed -e 1Rq a > out2 || fail=1
|
|---|
| 33 | compare_ a out2
|
|---|
| 34 |
|
|---|
| 35 | # Read two lines from a file, second time will be EOF
|
|---|
| 36 | # (implementation note: EOF from get_delim())
|
|---|
| 37 | printf "%s\n" x X y > exp3 || framework_failure_
|
|---|
| 38 | sed -e 1Rc -e 2Rc a > out3 || fail=1
|
|---|
| 39 | compare_ exp3 out3 || fail=1
|
|---|
| 40 |
|
|---|
| 41 | # Read two lines from an empty file, both will be EOF
|
|---|
| 42 | # (implementation note: EOF in before get_delim())
|
|---|
| 43 | sed -e 1Rd -e 2Rd a > out4 || fail=1
|
|---|
| 44 | compare_ a out4 || fail=1
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 | Exit $fail
|
|---|