Why do split(s,a,"c") and split(s,a,/c/) differ when s contains newline?
oguz-ismail opened this issue · 4 comments
oguz-ismail commented
See:
$ ./a.out 'BEGIN{split("axa\n",a,"x"); print "<"a[2]">"}'
<a>
$ ./a.out 'BEGIN{split("axa\n",a,/x/); print "<"a[2]">"}'
<a
>
$
This is reproducible on NetBSD, OpenBSD, and FreeBSDs awks too. But not on gawk, mawk, busybox awk and goawk.
What is the rationale for this behavior?
plan9 commented
no rationale, there is a bug when split's third argument is a single char.
oguz-ismail commented
arnoldrobbins commented
oguz-ismail ***@***.***> wrote:
@plan9 Given the explicit check for a newline here I though it was deliberate
https://github.com/onetrueawk/awk/blob/2bab10b60b3f4d3bbefdcb60410655f317d1a452/run.c#L1830-L1831
That looks like a copy/paste error to me; the check for newline
should probably be removed.
Arnold
plan9 commented
That looks like a copy/paste error to me; the check for newline should probably be removed. Arnold
think so. removed and tested yesterday, pushing shortly.
@oguz-ismail thanks for spotting the issue.