diff options
-rw-r--r-- | editors/sed.c | 8 | ||||
-rw-r--r-- | testsuite/sed/sed-next-line | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/editors/sed.c b/editors/sed.c index 00ed20892..8c77a0ffc 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -985,11 +985,19 @@ static void process_file(FILE * file) | |||
985 | next_line = NULL; | 985 | next_line = NULL; |
986 | break; | 986 | break; |
987 | case 'n': /* Read next line from input */ | 987 | case 'n': /* Read next line from input */ |
988 | if (!be_quiet) { | ||
989 | puts(pattern_space); | ||
990 | } | ||
988 | if (next_line) { | 991 | if (next_line) { |
989 | free(pattern_space); | 992 | free(pattern_space); |
990 | pattern_space = next_line; | 993 | pattern_space = next_line; |
991 | next_line = bb_get_chomped_line_from_file(file); | 994 | next_line = bb_get_chomped_line_from_file(file); |
992 | linenum++; | 995 | linenum++; |
996 | } else { | ||
997 | /* Jump to end of script and exist */ | ||
998 | deleted = 1; | ||
999 | free(next_line); | ||
1000 | next_line = NULL; | ||
993 | } | 1001 | } |
994 | break; | 1002 | break; |
995 | case 'N': /* Append the next line to the current line */ | 1003 | case 'N': /* Append the next line to the current line */ |
diff --git a/testsuite/sed/sed-next-line b/testsuite/sed/sed-next-line new file mode 100644 index 000000000..38fe20cf2 --- /dev/null +++ b/testsuite/sed/sed-next-line | |||
@@ -0,0 +1,12 @@ | |||
1 | busybox sed 'n;p'>output <<EOF | ||
2 | a | ||
3 | b | ||
4 | c | ||
5 | EOF | ||
6 | cmp -s output - <<EOF | ||
7 | a | ||
8 | b | ||
9 | b | ||
10 | c | ||
11 | c | ||
12 | EOF | ||