Skip to content

Commit

Permalink
Make sure $IFS is not an empty string
Browse files Browse the repository at this point in the history
While here, shorten the name of the variable.
  • Loading branch information
mptre committed Jul 9, 2017
1 parent edbc0cb commit e894dd0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pick.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ usage(void)
char *
get_choices(void)
{
char *buf, *description, *field_separators, *start, *stop;
char *buf, *description, *ifs, *start, *stop;
ssize_t n;
size_t length = 0;
size_t size = BUFSIZ;

if ((field_separators = getenv("IFS")) == NULL)
field_separators = " ";
if ((ifs = getenv("IFS")) == NULL || *ifs == '\0')
ifs = " ";

if ((buf = malloc(size)) == NULL)
err(1, NULL);
Expand Down Expand Up @@ -233,7 +233,7 @@ get_choices(void)
*stop = '\0';

if (descriptions &&
(description = eager_strpbrk(start, field_separators)))
(description = eager_strpbrk(start, ifs)))
*description++ = '\0';
else
description = "";
Expand Down

0 comments on commit e894dd0

Please sign in to comment.