This is a recent change in GNU grep as well (after 3.1)
function old new delta
grep_file 1215 1228 +13
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Prior to the patch, both -f and --first-only are in all cases either
no-op or ignored.
Without --tabs, --first-only is the default so specifying it is a no-op.
With --tabs, --all is implied, and --first-only is intended to reset this.
function old new delta
expand_main 690 694 +4
Signed-off-by: Mark Edgar <medgar123@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
From POSIX.1-2008:
The pattern_list's value shall consist of one or more patterns
separated by <newline> characters;
As such, given patterns need to be split at newline characters. Without
doing so, busybox grep will interpret the newline as part of the pattern
which is not in accordance with POSIX.
See also: https://bugs.busybox.net/show_bug.cgi?id=12721
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Grep currently special-cased empty pattern file to be the same as
pattern file with one empty line (empty pattern). That does mirror how
GNU grep behaves, except when -x is provided. In that case .* pattern
needs to be used instead.
Signed-off-by: Gray Wolf <wolf@wolfsden.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Since commit 1ff7002b1 (xargs: fix handling of quoted arguments, closes
11441) the -n option hasn't worked properly:
$ echo 1 2 3 | xargs -n 1 echo
1
2
3
$
Because state is now remembered between calls to process_stdin() it's
necessary to update the state before any premature return.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
As reported in bug 11441 when presented with a large number of quoted
arguments xargs can return 'argument line too long':
seq 10000 29999 | sed -e 's/^/"/' -e 's/$/"/' | busybox xargs echo
This happens because the variant of process_stdin() which handles quoted
arguments doesn't preserve state between calls. If the allowed number
of characters is exceeded part way through a quoted argument the next
call to process_stdin() incorrectly treats the terminating quote as a
starting quote, thus quoting all of the argument separators.
function old new delta
process_stdin 274 303 +29
xargs_main 731 745 +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 43/0) Total: 43 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
function old new delta
xc_program_print 712 735 +23
Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
function old new delta
zxc_vm_process 6884 6891 +7
Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This matches the behaviour of both GNU dc (as specified in
its man page), and BSD dc (where stack_popstring() pops
only if the head is a string.)
Add a couple of tests to verify this behavior.
function old new delta
zxc_vm_process 6882 6884 +2
Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
We found out that busybox -x -v is a bit broken:
ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -e 'aa.*' -e '.*bb.*'
aa bb cc
ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -v -e 'aa.*' -e '.*bb.*'
ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -e '.*aa.*' -e 'bb.*'
aa bb cc
ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -v -e '.*aa.*' -e 'bb.*'
aa bb cc
Last one is wrong.
This patch fixes the issue by making sure that the variable 'found'
never makes a transition from 1 to 0, as this would mean that
grep previously found a match on this input line.
Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Niko Vähäsarja <niko@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Unlike exit and return, delete strictly requires an arg, and derefs a
null pointer if executed without one.
Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Avoids an uninit pointer deref for some malformed ternary exprs.
Add a test that would crash in busybox before this fix.
Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This removes DAEMON_DOUBLE_FORK flag from bb_daemonize_or_rexec(),
as SSD was the only user.
Also includes fix for -S: now works without -a and -x,
does not print pids
(compat with "start-stop-daemon (OpenRC) 0.34.11 (Gentoo Linux)").
function old new delta
start_stop_daemon_main 1018 1084 +66
add_interface 99 103 +4
fail_hunk 139 136 -3
bb_daemonize_or_rexec 205 183 -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 70/-25) Total: 45 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>