diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/exec.c | 14 | ||||
-rw-r--r-- | Src/utils.c | 19 |
2 files changed, 20 insertions, 13 deletions
diff --git a/Src/exec.c b/Src/exec.c index e154d1249..216057aa7 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -5042,7 +5042,7 @@ execfuncdef(Estate state, Eprog redir_prog) Shfunc shf; char *s = NULL; int signum, nprg, sbeg, nstrs, npats, len, plen, i, htok = 0, ret = 0; - int nfunc = 0, anon_func = 0; + int anon_func = 0; Wordcode beg = state->pc, end; Eprog prog; Patprog *pp; @@ -5118,12 +5118,16 @@ execfuncdef(Estate state, Eprog redir_prog) /* * redir_prog is permanently allocated --- but if * this function has multiple names we need an additional - * one. + * one. Original redir_prog used with the last name + * because earlier functions are freed in case of duplicate + * names. */ - if (nfunc++ && redir_prog) + if (names && nonempty(names) && redir_prog) shf->redir = dupeprog(redir_prog, 0); - else + else { shf->redir = redir_prog; + redir_prog = 0; + } shfunc_set_sticky(shf); if (!names) { @@ -5203,7 +5207,7 @@ execfuncdef(Estate state, Eprog redir_prog) } if (!anon_func) setunderscore(""); - if (!nfunc && redir_prog) { + if (redir_prog) { /* For completeness, shouldn't happen */ freeeprog(redir_prog); } diff --git a/Src/utils.c b/Src/utils.c index 180693d67..b41851700 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1834,8 +1834,9 @@ adjustlines(int signalled) else shttyinfo.winsize.ws_row = zterm_lines; #endif /* TIOCGWINSZ */ - if (zterm_lines < 0) { - DPUTS(signalled, "BUG: Impossible TIOCGWINSZ rows"); + if (zterm_lines <= 0) { + DPUTS(signalled && zterm_lines < 0, + "BUG: Impossible TIOCGWINSZ rows"); zterm_lines = tclines > 0 ? tclines : 24; } @@ -1858,8 +1859,9 @@ adjustcolumns(int signalled) else shttyinfo.winsize.ws_col = zterm_columns; #endif /* TIOCGWINSZ */ - if (zterm_columns < 0) { - DPUTS(signalled, "BUG: Impossible TIOCGWINSZ cols"); + if (zterm_columns <= 0) { + DPUTS(signalled && zterm_columns < 0, + "BUG: Impossible TIOCGWINSZ cols"); zterm_columns = tccolumns > 0 ? tccolumns : 80; } @@ -2775,10 +2777,11 @@ checkrmall(char *s) const int max_count = 100; if ((rmd = opendir(unmeta(s)))) { int ignoredots = !isset(GLOBDOTS); - /* ### TODO: Passing ignoredots here is wrong. See workers/41672 - aka <https://bugs.debian.org/875460>. - */ - while (zreaddir(rmd, ignoredots)) { + char *fname; + + while ((fname = zreaddir(rmd, 1))) { + if (ignoredots && *fname == '.') + continue; count++; if (count > max_count) break; |