fixed a bug with expanding unquoted $* when the separator is not whitespace and one or more of the positional parameters ends with the separator, resulting in an extra blank field being generated; fixed an issue with adjusting SHLVL in subshells that caused the environment to be rebuilt too many times; fix to make sure function substitution doesn't leave the -v option unset

This commit is contained in:
Chet Ramey
2026-05-20 10:18:32 -04:00
parent 669b32f676
commit 2d4ba0c618
15 changed files with 503 additions and 36 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins -I${srcdir} \
ALLPROG = print truefalse sleep finfo logname basename dirname fdflags \
tty pathchk tee head mkdir rmdir mkfifo mktemp printenv id whoami \
uname sync push ln unlink realpath strftime mypid setpgid seq rm \
accept csv dsv cut stat getconf kv strptime chmod fltexpr jobid
accept csv dsv cut stat getconf kv strptime chmod fltexpr jobid rev
OTHERPROG = necho hello cat pushd asort
SUBDIRS = perl
+9 -3
View File
@@ -364,7 +364,7 @@ cutline (SHELL_VAR *v, arrayind_t ind, char *line, struct cutop *ops)
static int
cutfile (SHELL_VAR *v, WORD_LIST *list, struct cutop *ops)
{
int fd, unbuffered_read, r;
int fd, unbuffered_read, r, closefd;
char *line, *b;
size_t llen;
WORD_LIST *l;
@@ -378,11 +378,16 @@ cutfile (SHELL_VAR *v, WORD_LIST *list, struct cutop *ops)
l = list;
do
{
closefd = 0;
/* for each file */
if (l == 0 || (l->word->word[0] == '-' && l->word->word[1] == '\0'))
fd = 0;
else
fd = open (l->word->word, O_RDONLY);
{
fd = open (l->word->word, O_RDONLY);
closefd = fd != -1;
}
if (fd < 0)
{
file_error (l->word->word);
@@ -403,7 +408,8 @@ cutfile (SHELL_VAR *v, WORD_LIST *list, struct cutop *ops)
r = cutline (v, ind, line, ops); /* can modify line */
ind += r;
}
if (fd > 0)
if (closefd)
close (fd);
QUIT;