aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2021-07-19 22:47:30 -0600
committerWarner Losh <imp@FreeBSD.org>2021-07-20 08:10:50 -0600
commit45dab2a7e08ac950c8838e1b01f8d8439e2f0f7c (patch)
treed3e4410d7884d799040a074186836a78d1407e72
parentc0f4e97e4561ff42544e92512bbaf3d7d1f6a671 (diff)
downloadone-true-awk-45dab2a7e08ac950c8838e1b01f8d8439e2f0f7c.tar.gz
awk: Make -F '' and -v FS="" behave the same
IEEE Std 1003.1-2008 mandates that -F str be treated the same as -v FS=str. For a null string, this was not the case. Since awk(1) documents that a null string for FS has a specific behavior, make -F '' behave consistently with -v FS="". PR: upstream issue: https://github.com/onetrueawk/awk/issues/127 Sponsored by: Netflix
-rw-r--r--main.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/main.c b/main.c
index f393634..4e68bfb 100644
--- a/main.c
+++ b/main.c
@@ -91,9 +91,7 @@ setfs(char *p)
/* wart: t=>\t */
if (p[0] == 't' && p[1] == '\0')
return "\t";
- else if (p[0] != '\0')
- return p;
- return NULL;
+ return p;
}
static char *
@@ -169,8 +167,6 @@ int main(int argc, char *argv[])
break;
case 'F': /* set field separator */
fs = setfs(getarg(&argc, &argv, "no field separator"));
- if (fs == NULL)
- WARNING("field separator FS is empty");
break;
case 'v': /* -v a=1 to be done NOW. one -v for each */
vn = getarg(&argc, &argv, "no variable name");