Skip to content

Commit

Permalink
awk: Make -F '' and -v FS="" behave the same
Browse files Browse the repository at this point in the history
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:			241441
Upstream issue:		onetrueawk/awk#127
Upstream pull request:	onetrueawk/awk#128
MFC After:		2 weeks
Sponsored by:		Netflix

(cherry picked from commit a2e3e11)
  • Loading branch information
bsdimp committed Jul 30, 2021
1 parent 5193261 commit f4ed53c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions contrib/one-true-awk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit f4ed53c

Please sign in to comment.