Unexpected split behavior

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I read about Awk split behavior here:
[...] the fs argument to the split function (see String Functions) shall
be interpreted as extended regular expressions. These can be either ERE
tokens or arbitrary expressions, and shall be interpreted in the same manner
as the right-hand side of the~or!~operator.
and:
If the right-hand operand is any expression other than the lexical token
ERE, the string value of the expression shall be interpreted as an
extended regular expression, including the escape conventions described above.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_04
However I have noticed an unexpected result, with this code:
BEGIN
print split("te.st", q, ".")
I would expect the . to represent any character, and for the result to be 6.
However all my tests returned 2. Running this code gives the expected 6:
BEGIN
print split("te.st", q, /./)
Tested with:
- gawk
- gawk --posix
- mawk 1.3.4
- mawk 1.3.3
- nawk (original-awk)
Am I misunderstanding the documentation or is this an error?
awk posix gawk mawk
add a comment |
up vote
1
down vote
favorite
I read about Awk split behavior here:
[...] the fs argument to the split function (see String Functions) shall
be interpreted as extended regular expressions. These can be either ERE
tokens or arbitrary expressions, and shall be interpreted in the same manner
as the right-hand side of the~or!~operator.
and:
If the right-hand operand is any expression other than the lexical token
ERE, the string value of the expression shall be interpreted as an
extended regular expression, including the escape conventions described above.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_04
However I have noticed an unexpected result, with this code:
BEGIN
print split("te.st", q, ".")
I would expect the . to represent any character, and for the result to be 6.
However all my tests returned 2. Running this code gives the expected 6:
BEGIN
print split("te.st", q, /./)
Tested with:
- gawk
- gawk --posix
- mawk 1.3.4
- mawk 1.3.3
- nawk (original-awk)
Am I misunderstanding the documentation or is this an error?
awk posix gawk mawk
It is usuall regex to be entered in/.../format. It is also described in gawk documentation here (scroll down to split function): gnu.org/software/gawk/manual/html_node/String-Functions.html
– George Vasiliou
Nov 24 at 15:25
I've submitted a bug report to GNU awk and its docs have been changed to mention this behavior explicitly.
– mosvy
Nov 27 at 12:03
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I read about Awk split behavior here:
[...] the fs argument to the split function (see String Functions) shall
be interpreted as extended regular expressions. These can be either ERE
tokens or arbitrary expressions, and shall be interpreted in the same manner
as the right-hand side of the~or!~operator.
and:
If the right-hand operand is any expression other than the lexical token
ERE, the string value of the expression shall be interpreted as an
extended regular expression, including the escape conventions described above.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_04
However I have noticed an unexpected result, with this code:
BEGIN
print split("te.st", q, ".")
I would expect the . to represent any character, and for the result to be 6.
However all my tests returned 2. Running this code gives the expected 6:
BEGIN
print split("te.st", q, /./)
Tested with:
- gawk
- gawk --posix
- mawk 1.3.4
- mawk 1.3.3
- nawk (original-awk)
Am I misunderstanding the documentation or is this an error?
awk posix gawk mawk
I read about Awk split behavior here:
[...] the fs argument to the split function (see String Functions) shall
be interpreted as extended regular expressions. These can be either ERE
tokens or arbitrary expressions, and shall be interpreted in the same manner
as the right-hand side of the~or!~operator.
and:
If the right-hand operand is any expression other than the lexical token
ERE, the string value of the expression shall be interpreted as an
extended regular expression, including the escape conventions described above.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_04
However I have noticed an unexpected result, with this code:
BEGIN
print split("te.st", q, ".")
I would expect the . to represent any character, and for the result to be 6.
However all my tests returned 2. Running this code gives the expected 6:
BEGIN
print split("te.st", q, /./)
Tested with:
- gawk
- gawk --posix
- mawk 1.3.4
- mawk 1.3.3
- nawk (original-awk)
Am I misunderstanding the documentation or is this an error?
awk posix gawk mawk
awk posix gawk mawk
edited Nov 27 at 12:35
ilkkachu
54.1k782147
54.1k782147
asked Nov 24 at 14:41
Steven Penny
2,47721737
2,47721737
It is usuall regex to be entered in/.../format. It is also described in gawk documentation here (scroll down to split function): gnu.org/software/gawk/manual/html_node/String-Functions.html
– George Vasiliou
Nov 24 at 15:25
I've submitted a bug report to GNU awk and its docs have been changed to mention this behavior explicitly.
– mosvy
Nov 27 at 12:03
add a comment |
It is usuall regex to be entered in/.../format. It is also described in gawk documentation here (scroll down to split function): gnu.org/software/gawk/manual/html_node/String-Functions.html
– George Vasiliou
Nov 24 at 15:25
I've submitted a bug report to GNU awk and its docs have been changed to mention this behavior explicitly.
– mosvy
Nov 27 at 12:03
It is usuall regex to be entered in
/.../ format. It is also described in gawk documentation here (scroll down to split function): gnu.org/software/gawk/manual/html_node/String-Functions.html– George Vasiliou
Nov 24 at 15:25
It is usuall regex to be entered in
/.../ format. It is also described in gawk documentation here (scroll down to split function): gnu.org/software/gawk/manual/html_node/String-Functions.html– George Vasiliou
Nov 24 at 15:25
I've submitted a bug report to GNU awk and its docs have been changed to mention this behavior explicitly.
– mosvy
Nov 27 at 12:03
I've submitted a bug report to GNU awk and its docs have been changed to mention this behavior explicitly.
– mosvy
Nov 27 at 12:03
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
This is not an error; it's just that the standard isn't clear enough while trying to codify the existing practice.
The mawk(1) manual is more explicit:
split(expr, A, sep)works as follows:
...
(2) If
sep = " "(a single space), then<SPACE>is trimmed from the
front and back ofexpr, andsepbecomes<SPACE>. mawk defines
<SPACE>as the regular expression/[ tn]+/.
Otherwisesepis treated as a regular expression, except that
meta-characters are ignored for a string of length 1, e.g.,
split(x, A, "*")andsplit(x, A, /*/)are the same.
Also, the GNU awk manual from the current sources:
split(s, a [, r [, seps] ])
...
Splitting behaves identically to field splitting, described above.
In particular, ifris a single-character string, that string acts as
the separator, even if it happens to be a regular expression
metacharacter.
This is the description from the susv4 standard:
An extended regular expression can be used to separate fields by assigning a
string containing the expression to the built-in variable FS, either
directly or as a consequence of using the-F sepstringoption. The
default value of the FS variable shall be a single <space>. The
following describes FS behavior:
- If FS is a null string, the behavior is unspecified.
If FS is a single character:
a. If FS is <space>, skip leading and trailing <blank> and
<newline> characters; fields shall be delimited by sets of one or
more <blank> or <newline> characters.
b. Otherwise, if FS is any other character c, fields shall be delimited
by each single occurrence of c.
Otherwise, the string value of FS shall be considered to be an
extended regular expression. Each occurrence of a sequence matching the
extended regular expression shall delimit fields.
Your example matches 2.b.
Even if that explicitly mentions FS, it's same behavior with any argument used
instead of it as the 3rd argument to split in all awk implementations, including in the case where that argument is a space.
It's unlikely that behavior will ever change, because the FS variable is just a string (awk doesn't have regexp objects, like javascript or perl; you cannot assign a regexp to a variable, as in a=/./ or $a=qr/./); it's the split function (called either implicitly or explicitly) which does interpret its argument as described above.
The origin of this behavior may be compatibility with the "old" awk, where FS (or the 3rd argument to split) was always treated as a single character. Example (on unix v7):
$ awk 'BEGINFS="."; print split("foo.bar.baz", a, "bar"); print a[2] '
3
ar.
$ awk 'BEGINFS="."; print split("foo.bar.baz", a, /bar/); print a[2] '
awk: syntax error near line 1
awk: illegal statement near line 1
Bus error - core dumped
1
Not that using.as a regex to split on makes much sense anyway, it would destroy the string and return the number of characters plus one, and there are easier ways to get that. I don't think there are other single-character REs that would make sense here either (but I might be wrong).
– ilkkachu
Nov 27 at 12:52
1
awk -F'|',awk -F.,awk -F+,awk -F'$',awk -F'^',awk -F''are common. Note that in the originalawk,awk -Ftmeant split on tab (back then as you say, only the first character was used). That's one case where backward compatibility was not maintained with nawk. Here, with POSIXawk, you can always useFS = "(.)"for FS to be the regexp matching a single character (.1would also work but is less portable).
– Stéphane Chazelas
Nov 27 at 13:00
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
This is not an error; it's just that the standard isn't clear enough while trying to codify the existing practice.
The mawk(1) manual is more explicit:
split(expr, A, sep)works as follows:
...
(2) If
sep = " "(a single space), then<SPACE>is trimmed from the
front and back ofexpr, andsepbecomes<SPACE>. mawk defines
<SPACE>as the regular expression/[ tn]+/.
Otherwisesepis treated as a regular expression, except that
meta-characters are ignored for a string of length 1, e.g.,
split(x, A, "*")andsplit(x, A, /*/)are the same.
Also, the GNU awk manual from the current sources:
split(s, a [, r [, seps] ])
...
Splitting behaves identically to field splitting, described above.
In particular, ifris a single-character string, that string acts as
the separator, even if it happens to be a regular expression
metacharacter.
This is the description from the susv4 standard:
An extended regular expression can be used to separate fields by assigning a
string containing the expression to the built-in variable FS, either
directly or as a consequence of using the-F sepstringoption. The
default value of the FS variable shall be a single <space>. The
following describes FS behavior:
- If FS is a null string, the behavior is unspecified.
If FS is a single character:
a. If FS is <space>, skip leading and trailing <blank> and
<newline> characters; fields shall be delimited by sets of one or
more <blank> or <newline> characters.
b. Otherwise, if FS is any other character c, fields shall be delimited
by each single occurrence of c.
Otherwise, the string value of FS shall be considered to be an
extended regular expression. Each occurrence of a sequence matching the
extended regular expression shall delimit fields.
Your example matches 2.b.
Even if that explicitly mentions FS, it's same behavior with any argument used
instead of it as the 3rd argument to split in all awk implementations, including in the case where that argument is a space.
It's unlikely that behavior will ever change, because the FS variable is just a string (awk doesn't have regexp objects, like javascript or perl; you cannot assign a regexp to a variable, as in a=/./ or $a=qr/./); it's the split function (called either implicitly or explicitly) which does interpret its argument as described above.
The origin of this behavior may be compatibility with the "old" awk, where FS (or the 3rd argument to split) was always treated as a single character. Example (on unix v7):
$ awk 'BEGINFS="."; print split("foo.bar.baz", a, "bar"); print a[2] '
3
ar.
$ awk 'BEGINFS="."; print split("foo.bar.baz", a, /bar/); print a[2] '
awk: syntax error near line 1
awk: illegal statement near line 1
Bus error - core dumped
1
Not that using.as a regex to split on makes much sense anyway, it would destroy the string and return the number of characters plus one, and there are easier ways to get that. I don't think there are other single-character REs that would make sense here either (but I might be wrong).
– ilkkachu
Nov 27 at 12:52
1
awk -F'|',awk -F.,awk -F+,awk -F'$',awk -F'^',awk -F''are common. Note that in the originalawk,awk -Ftmeant split on tab (back then as you say, only the first character was used). That's one case where backward compatibility was not maintained with nawk. Here, with POSIXawk, you can always useFS = "(.)"for FS to be the regexp matching a single character (.1would also work but is less portable).
– Stéphane Chazelas
Nov 27 at 13:00
add a comment |
up vote
2
down vote
This is not an error; it's just that the standard isn't clear enough while trying to codify the existing practice.
The mawk(1) manual is more explicit:
split(expr, A, sep)works as follows:
...
(2) If
sep = " "(a single space), then<SPACE>is trimmed from the
front and back ofexpr, andsepbecomes<SPACE>. mawk defines
<SPACE>as the regular expression/[ tn]+/.
Otherwisesepis treated as a regular expression, except that
meta-characters are ignored for a string of length 1, e.g.,
split(x, A, "*")andsplit(x, A, /*/)are the same.
Also, the GNU awk manual from the current sources:
split(s, a [, r [, seps] ])
...
Splitting behaves identically to field splitting, described above.
In particular, ifris a single-character string, that string acts as
the separator, even if it happens to be a regular expression
metacharacter.
This is the description from the susv4 standard:
An extended regular expression can be used to separate fields by assigning a
string containing the expression to the built-in variable FS, either
directly or as a consequence of using the-F sepstringoption. The
default value of the FS variable shall be a single <space>. The
following describes FS behavior:
- If FS is a null string, the behavior is unspecified.
If FS is a single character:
a. If FS is <space>, skip leading and trailing <blank> and
<newline> characters; fields shall be delimited by sets of one or
more <blank> or <newline> characters.
b. Otherwise, if FS is any other character c, fields shall be delimited
by each single occurrence of c.
Otherwise, the string value of FS shall be considered to be an
extended regular expression. Each occurrence of a sequence matching the
extended regular expression shall delimit fields.
Your example matches 2.b.
Even if that explicitly mentions FS, it's same behavior with any argument used
instead of it as the 3rd argument to split in all awk implementations, including in the case where that argument is a space.
It's unlikely that behavior will ever change, because the FS variable is just a string (awk doesn't have regexp objects, like javascript or perl; you cannot assign a regexp to a variable, as in a=/./ or $a=qr/./); it's the split function (called either implicitly or explicitly) which does interpret its argument as described above.
The origin of this behavior may be compatibility with the "old" awk, where FS (or the 3rd argument to split) was always treated as a single character. Example (on unix v7):
$ awk 'BEGINFS="."; print split("foo.bar.baz", a, "bar"); print a[2] '
3
ar.
$ awk 'BEGINFS="."; print split("foo.bar.baz", a, /bar/); print a[2] '
awk: syntax error near line 1
awk: illegal statement near line 1
Bus error - core dumped
1
Not that using.as a regex to split on makes much sense anyway, it would destroy the string and return the number of characters plus one, and there are easier ways to get that. I don't think there are other single-character REs that would make sense here either (but I might be wrong).
– ilkkachu
Nov 27 at 12:52
1
awk -F'|',awk -F.,awk -F+,awk -F'$',awk -F'^',awk -F''are common. Note that in the originalawk,awk -Ftmeant split on tab (back then as you say, only the first character was used). That's one case where backward compatibility was not maintained with nawk. Here, with POSIXawk, you can always useFS = "(.)"for FS to be the regexp matching a single character (.1would also work but is less portable).
– Stéphane Chazelas
Nov 27 at 13:00
add a comment |
up vote
2
down vote
up vote
2
down vote
This is not an error; it's just that the standard isn't clear enough while trying to codify the existing practice.
The mawk(1) manual is more explicit:
split(expr, A, sep)works as follows:
...
(2) If
sep = " "(a single space), then<SPACE>is trimmed from the
front and back ofexpr, andsepbecomes<SPACE>. mawk defines
<SPACE>as the regular expression/[ tn]+/.
Otherwisesepis treated as a regular expression, except that
meta-characters are ignored for a string of length 1, e.g.,
split(x, A, "*")andsplit(x, A, /*/)are the same.
Also, the GNU awk manual from the current sources:
split(s, a [, r [, seps] ])
...
Splitting behaves identically to field splitting, described above.
In particular, ifris a single-character string, that string acts as
the separator, even if it happens to be a regular expression
metacharacter.
This is the description from the susv4 standard:
An extended regular expression can be used to separate fields by assigning a
string containing the expression to the built-in variable FS, either
directly or as a consequence of using the-F sepstringoption. The
default value of the FS variable shall be a single <space>. The
following describes FS behavior:
- If FS is a null string, the behavior is unspecified.
If FS is a single character:
a. If FS is <space>, skip leading and trailing <blank> and
<newline> characters; fields shall be delimited by sets of one or
more <blank> or <newline> characters.
b. Otherwise, if FS is any other character c, fields shall be delimited
by each single occurrence of c.
Otherwise, the string value of FS shall be considered to be an
extended regular expression. Each occurrence of a sequence matching the
extended regular expression shall delimit fields.
Your example matches 2.b.
Even if that explicitly mentions FS, it's same behavior with any argument used
instead of it as the 3rd argument to split in all awk implementations, including in the case where that argument is a space.
It's unlikely that behavior will ever change, because the FS variable is just a string (awk doesn't have regexp objects, like javascript or perl; you cannot assign a regexp to a variable, as in a=/./ or $a=qr/./); it's the split function (called either implicitly or explicitly) which does interpret its argument as described above.
The origin of this behavior may be compatibility with the "old" awk, where FS (or the 3rd argument to split) was always treated as a single character. Example (on unix v7):
$ awk 'BEGINFS="."; print split("foo.bar.baz", a, "bar"); print a[2] '
3
ar.
$ awk 'BEGINFS="."; print split("foo.bar.baz", a, /bar/); print a[2] '
awk: syntax error near line 1
awk: illegal statement near line 1
Bus error - core dumped
This is not an error; it's just that the standard isn't clear enough while trying to codify the existing practice.
The mawk(1) manual is more explicit:
split(expr, A, sep)works as follows:
...
(2) If
sep = " "(a single space), then<SPACE>is trimmed from the
front and back ofexpr, andsepbecomes<SPACE>. mawk defines
<SPACE>as the regular expression/[ tn]+/.
Otherwisesepis treated as a regular expression, except that
meta-characters are ignored for a string of length 1, e.g.,
split(x, A, "*")andsplit(x, A, /*/)are the same.
Also, the GNU awk manual from the current sources:
split(s, a [, r [, seps] ])
...
Splitting behaves identically to field splitting, described above.
In particular, ifris a single-character string, that string acts as
the separator, even if it happens to be a regular expression
metacharacter.
This is the description from the susv4 standard:
An extended regular expression can be used to separate fields by assigning a
string containing the expression to the built-in variable FS, either
directly or as a consequence of using the-F sepstringoption. The
default value of the FS variable shall be a single <space>. The
following describes FS behavior:
- If FS is a null string, the behavior is unspecified.
If FS is a single character:
a. If FS is <space>, skip leading and trailing <blank> and
<newline> characters; fields shall be delimited by sets of one or
more <blank> or <newline> characters.
b. Otherwise, if FS is any other character c, fields shall be delimited
by each single occurrence of c.
Otherwise, the string value of FS shall be considered to be an
extended regular expression. Each occurrence of a sequence matching the
extended regular expression shall delimit fields.
Your example matches 2.b.
Even if that explicitly mentions FS, it's same behavior with any argument used
instead of it as the 3rd argument to split in all awk implementations, including in the case where that argument is a space.
It's unlikely that behavior will ever change, because the FS variable is just a string (awk doesn't have regexp objects, like javascript or perl; you cannot assign a regexp to a variable, as in a=/./ or $a=qr/./); it's the split function (called either implicitly or explicitly) which does interpret its argument as described above.
The origin of this behavior may be compatibility with the "old" awk, where FS (or the 3rd argument to split) was always treated as a single character. Example (on unix v7):
$ awk 'BEGINFS="."; print split("foo.bar.baz", a, "bar"); print a[2] '
3
ar.
$ awk 'BEGINFS="."; print split("foo.bar.baz", a, /bar/); print a[2] '
awk: syntax error near line 1
awk: illegal statement near line 1
Bus error - core dumped
edited Nov 27 at 12:26
answered Nov 24 at 15:13
mosvy
5,011323
5,011323
1
Not that using.as a regex to split on makes much sense anyway, it would destroy the string and return the number of characters plus one, and there are easier ways to get that. I don't think there are other single-character REs that would make sense here either (but I might be wrong).
– ilkkachu
Nov 27 at 12:52
1
awk -F'|',awk -F.,awk -F+,awk -F'$',awk -F'^',awk -F''are common. Note that in the originalawk,awk -Ftmeant split on tab (back then as you say, only the first character was used). That's one case where backward compatibility was not maintained with nawk. Here, with POSIXawk, you can always useFS = "(.)"for FS to be the regexp matching a single character (.1would also work but is less portable).
– Stéphane Chazelas
Nov 27 at 13:00
add a comment |
1
Not that using.as a regex to split on makes much sense anyway, it would destroy the string and return the number of characters plus one, and there are easier ways to get that. I don't think there are other single-character REs that would make sense here either (but I might be wrong).
– ilkkachu
Nov 27 at 12:52
1
awk -F'|',awk -F.,awk -F+,awk -F'$',awk -F'^',awk -F''are common. Note that in the originalawk,awk -Ftmeant split on tab (back then as you say, only the first character was used). That's one case where backward compatibility was not maintained with nawk. Here, with POSIXawk, you can always useFS = "(.)"for FS to be the regexp matching a single character (.1would also work but is less portable).
– Stéphane Chazelas
Nov 27 at 13:00
1
1
Not that using
. as a regex to split on makes much sense anyway, it would destroy the string and return the number of characters plus one, and there are easier ways to get that. I don't think there are other single-character REs that would make sense here either (but I might be wrong).– ilkkachu
Nov 27 at 12:52
Not that using
. as a regex to split on makes much sense anyway, it would destroy the string and return the number of characters plus one, and there are easier ways to get that. I don't think there are other single-character REs that would make sense here either (but I might be wrong).– ilkkachu
Nov 27 at 12:52
1
1
awk -F'|', awk -F., awk -F+, awk -F'$', awk -F'^', awk -F'' are common. Note that in the original awk, awk -Ft meant split on tab (back then as you say, only the first character was used). That's one case where backward compatibility was not maintained with nawk. Here, with POSIX awk, you can always use FS = "(.)" for FS to be the regexp matching a single character (.1 would also work but is less portable).– Stéphane Chazelas
Nov 27 at 13:00
awk -F'|', awk -F., awk -F+, awk -F'$', awk -F'^', awk -F'' are common. Note that in the original awk, awk -Ft meant split on tab (back then as you say, only the first character was used). That's one case where backward compatibility was not maintained with nawk. Here, with POSIX awk, you can always use FS = "(.)" for FS to be the regexp matching a single character (.1 would also work but is less portable).– Stéphane Chazelas
Nov 27 at 13:00
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483870%2funexpected-split-behavior%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It is usuall regex to be entered in
/.../format. It is also described in gawk documentation here (scroll down to split function): gnu.org/software/gawk/manual/html_node/String-Functions.html– George Vasiliou
Nov 24 at 15:25
I've submitted a bug report to GNU awk and its docs have been changed to mention this behavior explicitly.
– mosvy
Nov 27 at 12:03