A test and fix for the sed 'n' command
This commit is contained in:
parent
7b35121297
commit
6e5687abc3
@ -985,11 +985,19 @@ static void process_file(FILE * file)
|
|||||||
next_line = NULL;
|
next_line = NULL;
|
||||||
break;
|
break;
|
||||||
case 'n': /* Read next line from input */
|
case 'n': /* Read next line from input */
|
||||||
|
if (!be_quiet) {
|
||||||
|
puts(pattern_space);
|
||||||
|
}
|
||||||
if (next_line) {
|
if (next_line) {
|
||||||
free(pattern_space);
|
free(pattern_space);
|
||||||
pattern_space = next_line;
|
pattern_space = next_line;
|
||||||
next_line = bb_get_chomped_line_from_file(file);
|
next_line = bb_get_chomped_line_from_file(file);
|
||||||
linenum++;
|
linenum++;
|
||||||
|
} else {
|
||||||
|
/* Jump to end of script and exist */
|
||||||
|
deleted = 1;
|
||||||
|
free(next_line);
|
||||||
|
next_line = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'N': /* Append the next line to the current line */
|
case 'N': /* Append the next line to the current line */
|
||||||
|
12
testsuite/sed/sed-next-line
Normal file
12
testsuite/sed/sed-next-line
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
busybox sed 'n;p'>output <<EOF
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
EOF
|
||||||
|
cmp -s output - <<EOF
|
||||||
|
a
|
||||||
|
b
|
||||||
|
b
|
||||||
|
c
|
||||||
|
c
|
||||||
|
EOF
|
Loading…
Reference in New Issue
Block a user