* [tbm@cyrius.com: Bug#130817: zsh's echo doesn't error if device is full] @ 2002-01-27 20:21 Clint Adams 2002-01-27 21:46 ` Bart Schaefer 0 siblings, 1 reply; 5+ messages in thread From: Clint Adams @ 2002-01-27 20:21 UTC (permalink / raw) To: zsh-workers I tried putting some error-checking in bin_print, but it didn't seem to make much difference. ----- Forwarded message from Martin Michlmayr <tbm@cyrius.com> ----- zsh's echo should print an error when it fails because the device is full. 1250:tbm@fisch: ~] /bin/echo foo > b /bin/echo: write error: No space left on device zsh: exit 1 /bin/echo foo > b 1251:tbm@fisch: ~] echo foo > b -- System Information Debian Release: 3.0 Architecture: i386 Kernel: Linux fisch 2.4.16 #6 Wed Dec 26 15:44:54 CET 2001 i686 Locale: LANG=en_US, LC_CTYPE=en_US Versions of packages zsh depends on: ii libc6 2.2.4-7 GNU C Library: Shared libraries an ii libcap1 1:1.10-12 support for getting/setting POSIX. ii libncurses5 5.2.20010318-3 Shared libraries for terminal hand -- Martin Michlmayr tbm@cyrius.com ----- End forwarded message ----- ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tbm@cyrius.com: Bug#130817: zsh's echo doesn't error if device is full] 2002-01-27 20:21 [tbm@cyrius.com: Bug#130817: zsh's echo doesn't error if device is full] Clint Adams @ 2002-01-27 21:46 ` Bart Schaefer 2002-01-27 22:42 ` Clint Adams 0 siblings, 1 reply; 5+ messages in thread From: Bart Schaefer @ 2002-01-27 21:46 UTC (permalink / raw) To: Clint Adams, zsh-workers On Jan 27, 3:21pm, Clint Adams wrote: } Subject: [tbm@cyrius.com: Bug#130817: zsh's echo doesn't error if device i } } I tried putting some error-checking in bin_print, but it didn't seem to } make much difference. I suspect it's because bin_print() is using fprintf(), so the output is buffered by the stdio library and the error doesn't occur until the stream is flushed. There are a number of places in bin_print() that look something like: if (fout != stdout) fclose(fout); Try changing all of those to the equivalent of: if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { zwarnnam(name, "write error: %e", NULL, 0); ret = 1; } -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tbm@cyrius.com: Bug#130817: zsh's echo doesn't error if device is full] 2002-01-27 21:46 ` Bart Schaefer @ 2002-01-27 22:42 ` Clint Adams 2002-01-27 23:06 ` Clint Adams 0 siblings, 1 reply; 5+ messages in thread From: Clint Adams @ 2002-01-27 22:42 UTC (permalink / raw) To: Bart Schaefer; +Cc: zsh-workers > There are a number of places in bin_print() that look something like: > > if (fout != stdout) > fclose(fout); > > Try changing all of those to the equivalent of: > > if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { > zwarnnam(name, "write error: %e", NULL, 0); > ret = 1; > } That did the trick. Patch is bloated with reindentation. Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.65 diff -u -r1.65 builtin.c --- Src/builtin.c 2002/01/26 21:03:36 1.65 +++ Src/builtin.c 2002/01/27 22:40:59 @@ -241,7 +241,7 @@ /* while arguments look like options ... */ while (arg && ((sense = (*arg == '-')) || - ((flags & BINF_PLUSOPTS) && *arg == '+')) && + ((flags & BINF_PLUSOPTS) && *arg == '+')) && ((flags & BINF_PLUSOPTS) || !atoi(arg))) { /* unrecognised options to echo etc. are not really options */ if (flags & BINF_ECHOPTS) { @@ -296,7 +296,7 @@ } arg = (char *) ugetnode(args); /* for the "print" builtin, the options after -R are treated as - options to "echo" and -f takes an extra argument */ + options to "echo" and -f takes an extra argument */ if (flags & BINF_PRINTOPTS) { if (ops['R'] && !ops['f']) { optstr = "ne"; @@ -448,13 +448,13 @@ /* Take arguments literally -- do not glob */ queue_signals(); for (; *argv; argv++) { - if ((hn = ht->getnode2(ht, *argv))) { - scanfunc(hn, 0); - } else { - zwarnnam(name, "no such hash table element: %s", *argv, 0); - returnval = 1; - } + if ((hn = ht->getnode2(ht, *argv))) { + scanfunc(hn, 0); + } else { + zwarnnam(name, "no such hash table element: %s", *argv, 0); + returnval = 1; } + } unqueue_signals(); return returnval; } @@ -524,19 +524,19 @@ } args++; } - doneoptions: + doneoptions: inittyptab(); /* Show the parameters, possibly with values */ queue_signals(); if (!hadopt && !*args) scanhashtable(paramtab, 1, 0, 0, paramtab->printnode, - hadplus ? PRINT_NAMEONLY : 0); + hadplus ? PRINT_NAMEONLY : 0); if (array && !*args) { /* display arrays */ scanhashtable(paramtab, 1, PM_ARRAY, 0, paramtab->printnode, - hadplus ? PRINT_NAMEONLY : 0); + hadplus ? PRINT_NAMEONLY : 0); } if (!*args && !hadend) { unqueue_signals(); @@ -608,7 +608,7 @@ LinkList l; /* with the -v option, provide a numbered list of directories, starting at - zero */ + zero */ queue_signals(); if (ops['v']) { LinkNode node; @@ -716,7 +716,7 @@ } while (*++s); for (s = *argv; *++s; ops[STOUC(*s)] = 1); } - brk: + brk: chasinglinks = ops['P'] || (isset(CHASELINKS) && !ops['L']); queue_signals(); zpushnode(dirstack, ztrdup(pwd)); @@ -865,8 +865,8 @@ dest = buf; #endif nocdpath = dest[0] == '.' && - (dest[1] == '/' || !dest[1] || (dest[1] == '.' && - (dest[2] == '/' || !dest[2]))); + (dest[1] == '/' || !dest[1] || (dest[1] == '.' && + (dest[2] == '/' || !dest[2]))); /* * If we have an absolute path, use it as-is only @@ -884,7 +884,7 @@ if (!(*pp)[0] || ((*pp)[0] == '.' && (*pp)[1] == '\0')) hasdot = 1; /* if there is no . in cdpath (or it is not being used), try the directory - as-is (i.e. from .) */ + as-is (i.e. from .) */ if (!hasdot) { if ((ret = cd_try_chdir(NULL, dest, hard))) return ret; @@ -892,7 +892,7 @@ eno = errno; } /* if cdpath is being used, try given directory relative to each element in - cdpath in turn */ + cdpath in turn */ if (!nocdpath) for (pp = cdpath; *pp; pp++) { if ((ret = cd_try_chdir(*pp, dest, hard))) { @@ -916,8 +916,8 @@ } /* If we got here, it means that we couldn't chdir to any of the - multitudinous possible paths allowed by zsh. We've run out of options! - Add more here! */ + multitudinous possible paths allowed by zsh. We've run out of options! + Add more here! */ zwarnnam(cnam, "%e: %s", dest, eno); return NULL; } @@ -1045,7 +1045,7 @@ } /* shift around the pwd variables, to make oldpwd and pwd relate to the - current (i.e. new) pwd */ + current (i.e. new) pwd */ zsfree(oldpwd); oldpwd = pwd; setjobpwd(); @@ -1074,7 +1074,7 @@ /* handle directory stack sizes out of range */ if (dirstacksize > 0) { int remove = countlinknodes(dirstack) - - (dirstacksize < 2 ? 2 : dirstacksize); + (dirstacksize < 2 ? 2 : dirstacksize); while (remove-- >= 0) zsfree(remnode(dirstack, lastnode(dirstack))); } @@ -1116,7 +1116,7 @@ #ifdef HAVE_SUPERROOT /* allow /.. segments to remain */ while (*src == '/' && src[1] == '.' && src[2] == '.' && - (!src[3] || src[3] == '/')) { + (!src[3] || src[3] == '/')) { *dest++ = '/'; *dest++ = '.'; *dest++ = '.'; @@ -1137,7 +1137,7 @@ src++; } /* if we are at the end of the input path, remove a trailing / (if it - exists), and return ct */ + exists), and return ct */ if (!*src) { while (dest > d0 + 1 && dest[-1] == '/') dest--; @@ -1303,7 +1303,7 @@ /* default values of first and last, and range checking */ if (first == -1) { first = ops['l']? addhistnum(curline.histnum,-16,0) - : addhistnum(curline.histnum,-1,0); + : addhistnum(curline.histnum,-1,0); } if (last == -1) last = ops['l']? addhistnum(curline.histnum,-1,0) : first; @@ -1329,8 +1329,8 @@ retval = 1; fil = gettempname(); if (((tempfd = open(fil, O_WRONLY | O_CREAT | O_EXCL | O_NOCTTY, 0600)) - == -1) || - ((out = fdopen(tempfd, "w")) == NULL)) { + == -1) || + ((out = fdopen(tempfd, "w")) == NULL)) { unqueue_signals(); zwarnnam("fc", "can't open temp file: %e", NULL, errno); } else { @@ -1407,7 +1407,7 @@ /* loop over occurences of oldstr in s, replacing them with newstr */ while ((newpos = (char *)strstr(oldpos, oldstr))) { newmem = (char *) zhalloc(1 + (newpos - s) - + strlen(newstr) + strlen(newpos + strlen(oldstr))); + + strlen(newstr) + strlen(newpos + strlen(oldstr))); ztrncpy(newmem, s, newpos - s); strcat(newmem, newstr); oldpos = newmem + strlen(newmem); @@ -1473,7 +1473,7 @@ ent->flags & HIST_FOREIGN? '*' : ' '); } /* output actual time (and possibly date) of execution of the - command, if required */ + command, if required */ if (d) { struct tm *ltm; ltm = localtime(&ent->stim); @@ -1579,7 +1579,7 @@ *s = '\0'; asg.value = s + 1; } else { - /* didn't find `=', so we only have a name */ + /* didn't find `=', so we only have a name */ asg.value = NULL; } return &asg; @@ -1634,8 +1634,8 @@ tc = 0; if (usepm || newspecial) { int chflags = ((off & pm->flags) | (on & ~pm->flags)) & - (PM_INTEGER|PM_EFLOAT|PM_FFLOAT|PM_HASHED| - PM_ARRAY|PM_TIED|PM_AUTOLOAD); + (PM_INTEGER|PM_EFLOAT|PM_FFLOAT|PM_HASHED| + PM_ARRAY|PM_TIED|PM_AUTOLOAD); /* keep the parameter if just switching between floating types */ if ((tc = chflags && chflags != (PM_EFLOAT|PM_FFLOAT))) usepm = 0; @@ -2237,7 +2237,7 @@ scanmatchtable(shfunctab, pprog, 0, DISABLED, shfunctab->printnode, pflags); } else { - /* apply the options to all functions matching the glob pattern */ + /* apply the options to all functions matching the glob pattern */ for (i = 0; i < shfunctab->hsize; i++) { for (shf = (Shfunc) shfunctab->nodes[i]; shf; shf = (Shfunc) shf->next) @@ -2347,7 +2347,7 @@ /* record pointer to next, since we may free this one */ next = (Param) pm->next; if ((!(pm->flags & PM_RESTRICTED) || - unset(RESTRICTED)) && + unset(RESTRICTED)) && pattry(pprog, pm->nam)) { unsetparam_pm(pm, 0, 1); match++; @@ -2840,7 +2840,7 @@ /* The argument is of the form foo=bar and we are not * * forcing a listing with -L, so define an alias */ aliastab->addnode(aliastab, ztrdup(asg->name), - createaliasnode(ztrdup(asg->value), flags1)); + createaliasnode(ztrdup(asg->value), flags1)); } else if ((a = (Alias) aliastab->getnode(aliastab, asg->name))) { /* display alias if appropriate */ if (!haveflags || @@ -2899,25 +2899,25 @@ char **first, *curarg, *flagch = "0+- #", save, nullstr = '\0'; zlong count; FILE *fout = stdout; - + mnumber mnumval; double doubleval; int intval; zlong zlongval; zulong zulongval; char *stringval; - + if (func == BIN_PRINTF) auxdata = *args++; if (auxdata) fmt = getkeystring(auxdata, &flen, ops['b'] ? 2 : 0, &nnl); first = args; - + /* -m option -- treat the first argument as a pattern and remove * arguments not matching */ if (ops['m']) { Patprog pprog; char **t, **p; - + tokenize(*args); if (!(pprog = patcompile(*args, PAT_STATIC, NULL))) { untokenize(*args); @@ -2940,7 +2940,7 @@ unmetafy(args[n], &len[n]); else args[n] = getkeystring(args[n], &len[n], ops['b'] ? 2 : - (func != BIN_ECHO && !ops['e']), &nnl); + (func != BIN_ECHO && !ops['e']), &nnl); /* -P option -- interpret as a prompt sequence */ if(ops['P']) { /* @@ -2949,14 +2949,14 @@ * instead. */ char *str = unmetafy(promptexpand(metafy(args[n], len[n], - META_NOALLOC), 0, NULL, NULL), &len[n]); + META_NOALLOC), 0, NULL, NULL), &len[n]); args[n] = dupstring(str); free(str); } /* -D option -- interpret as a directory, and use ~ */ if(ops['D']) { Nameddir d; - + queue_signals(); d = finddir(args[n]); if(d) { @@ -2969,7 +2969,7 @@ unqueue_signals(); } } - + /* -o and -O -- sort the arguments */ if (ops['o']) { if (fmt && !*args) return 0; @@ -3074,9 +3074,11 @@ } while (*ap); fputc(ops['N'] ? '\0' : '\n', fout); } - if (fout != stdout) - fclose(fout); - return 0; + if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { + zwarnnam(name, "write error: %e", NULL, errno); + ret = 1; + } + return ret; } /* normal output */ @@ -3088,9 +3090,12 @@ } if (!(ops['n'] || nnl)) fputc(ops['N'] ? '\0' : '\n', fout); - if (fout != stdout) - fclose(fout); - return 0; + if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { + zwarnnam(name, "write error: %e", NULL, errno); + ret = 1; + } + + return ret; } /* printf style output */ @@ -3128,7 +3133,7 @@ DPUTS(narg <= 0, "specified zero or negative arg"); if (narg > argc) { zwarnnam(name, "%d: argument specifier out of range", - 0, narg); + 0, narg); return 1; } else { if (narg > maxarg) maxarg = narg; @@ -3158,8 +3163,8 @@ c = endptr + 1; if (narg > argc || narg <= 0) { zwarnnam(name, - "%d: argument specifier out of range", - 0, narg); + "%d: argument specifier out of range", + 0, narg); return 1; } else { if (narg > maxarg) maxarg = narg; @@ -3185,8 +3190,8 @@ c = endptr + 1; if (narg > argc || narg <= 0) { zwarnnam(name, - "%d: argument specifier out of range", - 0, narg); + "%d: argument specifier out of range", + 0, narg); return 1; } else { if (narg > maxarg) maxarg = narg; @@ -3274,8 +3279,9 @@ } zwarnnam(name, "%s: invalid directive", start, 0); if (*c) c[1] = save; - if (fout != stdout) - fclose(fout); + if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { + zwarnnam(name, "write error: %e", NULL, errno); + } return 1; } @@ -3302,7 +3308,7 @@ ret = 1; } print_val(zlongval) - break; + break; case 2: if (curarg) { mnumval = matheval(curarg); @@ -3315,7 +3321,7 @@ ret = 1; } print_val(doubleval) - break; + break; case 3: #ifdef ZSH_64_BIT_UTYPE *d++ = 'l'; @@ -3328,7 +3334,7 @@ ret = 1; } print_val(zulongval) - } + } } } if (maxarg && (args - first > maxarg)) @@ -3336,11 +3342,13 @@ } if (maxarg) args = first + maxarg; - /* if there are remaining args, reuse format string */ + /* if there are remaining args, reuse format string */ } while (*args && args != first && !ops['r']); - if (fout != stdout) - fclose(fout); + if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { + zwarnnam(name, "write error: %e", NULL, errno); + ret = 1; + } return ret; } @@ -3450,7 +3458,7 @@ /* check for legality */ if(opch == ':' || !(p = memchr(optstr, opch, lenoptstr))) { p = "?"; -err: + err: zsfree(zoptarg); setsparam(var, ztrdup(p)); if(quiet) { @@ -3620,7 +3628,7 @@ } } if (from_where == 2 || (in_exit++ && from_where)) - return; + return; if (isset(MONITOR)) { /* send SIGHUP to any jobs left running */ @@ -3954,9 +3962,9 @@ } /* All possible special types of input have been exhausted. Take one line, - and assign words to the parameters until they run out. Leftover words go - onto the last parameter. If an array is specified, all the words become - separate elements of the array. */ + and assign words to the parameters until they run out. Leftover words go + onto the last parameter. If an array is specified, all the words become + separate elements of the array. */ zbuforig = zbuf = (!ops['z']) ? NULL : (nonempty(bufstack)) ? (char *) getlinknode(bufstack) : ztrdup(""); @@ -4070,7 +4078,7 @@ for (;;) { c = zread(izle, &readchar); /* \ at the end of a line introduces a continuation line, except in - raw mode (-r option) */ + raw mode (-r option) */ if (bslash && c == '\n') { bslash = 0; continue; @@ -4147,8 +4155,8 @@ /* use zbuf if possible */ if (zbuf) { /* If zbuf points to anything, it points to the next character in the - buffer. This may be a null byte to indicate EOF. If reading from the - buffer, move on the buffer pointer. */ + buffer. This may be a null byte to indicate EOF. If reading from the + buffer, move on the buffer pointer. */ if (*zbuf == Meta) return zbuf++, STOUC(*zbuf++ ^ 32); else @@ -4170,21 +4178,21 @@ #if defined(EAGAIN) || defined(EWOULDBLOCK) if (!retry && readfd == 0 && ( # ifdef EAGAIN - errno == EAGAIN + errno == EAGAIN # ifdef EWOULDBLOCK - || + || # endif /* EWOULDBLOCK */ # endif /* EAGAIN */ # ifdef EWOULDBLOCK - errno == EWOULDBLOCK + errno == EWOULDBLOCK # endif /* EWOULDBLOCK */ ) && setblock_stdin()) { retry = 1; continue; } else #endif /* EAGAIN || EWOULDBLOCK */ - if (errno == EINTR && !(errflag || retflag || breaks || contflag)) - continue; + if (errno == EINTR && !(errflag || retflag || breaks || contflag)) + continue; break; } return EOF; @@ -4456,10 +4464,10 @@ int whomask, umaskop, mask; /* More than one symbolic argument may be used at once, each separated - by commas. */ + by commas. */ for (;;) { /* First part of the argument -- who does this apply to? - u=owner, g=group, o=other. */ + u=owner, g=group, o=other. */ whomask = 0; while (*s == 'u' || *s == 'g' || *s == 'o' || *s == 'a') if (*s == 'u') ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tbm@cyrius.com: Bug#130817: zsh's echo doesn't error if device is full] 2002-01-27 22:42 ` Clint Adams @ 2002-01-27 23:06 ` Clint Adams 2002-01-27 23:23 ` Clint Adams 0 siblings, 1 reply; 5+ messages in thread From: Clint Adams @ 2002-01-27 23:06 UTC (permalink / raw) To: zsh-workers > That did the trick. Patch is bloated with reindentation. Here's the "backport" for 4.0.x: Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.46.4.4 diff -u -r1.46.4.4 builtin.c --- Src/builtin.c 2002/01/26 21:04:37 1.46.4.4 +++ Src/builtin.c 2002/01/27 23:03:29 @@ -240,7 +240,7 @@ /* while arguments look like options ... */ while (arg && ((sense = (*arg == '-')) || - ((flags & BINF_PLUSOPTS) && *arg == '+')) && + ((flags & BINF_PLUSOPTS) && *arg == '+')) && ((flags & BINF_PLUSOPTS) || !atoi(arg))) { /* unrecognised options to echo etc. are not really options */ if (flags & BINF_ECHOPTS) { @@ -295,7 +295,7 @@ } arg = (char *) ugetnode(args); /* for the "print" builtin, the options after -R are treated as - options to "echo" */ + options to "echo" */ if ((flags & BINF_PRINTOPTS) && ops['R']) { optstr = "ne"; flags |= BINF_ECHOPTS; @@ -438,13 +438,13 @@ /* Take arguments literally -- do not glob */ queue_signals(); for (; *argv; argv++) { - if ((hn = ht->getnode2(ht, *argv))) { - scanfunc(hn, 0); - } else { - zwarnnam(name, "no such hash table element: %s", *argv, 0); - returnval = 1; - } + if ((hn = ht->getnode2(ht, *argv))) { + scanfunc(hn, 0); + } else { + zwarnnam(name, "no such hash table element: %s", *argv, 0); + returnval = 1; } + } unqueue_signals(); return returnval; } @@ -514,19 +514,19 @@ } args++; } - doneoptions: + doneoptions: inittyptab(); /* Show the parameters, possibly with values */ queue_signals(); if (!hadopt && !*args) scanhashtable(paramtab, 1, 0, 0, paramtab->printnode, - hadplus ? PRINT_NAMEONLY : 0); + hadplus ? PRINT_NAMEONLY : 0); if (array && !*args) { /* display arrays */ scanhashtable(paramtab, 1, PM_ARRAY, 0, paramtab->printnode, - hadplus ? PRINT_NAMEONLY : 0); + hadplus ? PRINT_NAMEONLY : 0); } if (!*args && !hadend) { unqueue_signals(); @@ -598,7 +598,7 @@ LinkList l; /* with the -v option, provide a numbered list of directories, starting at - zero */ + zero */ queue_signals(); if (ops['v']) { LinkNode node; @@ -706,7 +706,7 @@ } while (*++s); for (s = *argv; *++s; ops[STOUC(*s)] = 1); } - brk: + brk: chasinglinks = ops['P'] || (isset(CHASELINKS) && !ops['L']); queue_signals(); zpushnode(dirstack, ztrdup(pwd)); @@ -855,8 +855,8 @@ dest = buf; #endif nocdpath = dest[0] == '.' && - (dest[1] == '/' || !dest[1] || (dest[1] == '.' && - (dest[2] == '/' || !dest[2]))); + (dest[1] == '/' || !dest[1] || (dest[1] == '.' && + (dest[2] == '/' || !dest[2]))); /* * If we have an absolute path, use it as-is only @@ -874,7 +874,7 @@ if (!(*pp)[0] || ((*pp)[0] == '.' && (*pp)[1] == '\0')) hasdot = 1; /* if there is no . in cdpath (or it is not being used), try the directory - as-is (i.e. from .) */ + as-is (i.e. from .) */ if (!hasdot) { if ((ret = cd_try_chdir(NULL, dest, hard))) return ret; @@ -882,7 +882,7 @@ eno = errno; } /* if cdpath is being used, try given directory relative to each element in - cdpath in turn */ + cdpath in turn */ if (!nocdpath) for (pp = cdpath; *pp; pp++) { if ((ret = cd_try_chdir(*pp, dest, hard))) { @@ -906,8 +906,8 @@ } /* If we got here, it means that we couldn't chdir to any of the - multitudinous possible paths allowed by zsh. We've run out of options! - Add more here! */ + multitudinous possible paths allowed by zsh. We've run out of options! + Add more here! */ zwarnnam(cnam, "%e: %s", dest, eno); return NULL; } @@ -1035,7 +1035,7 @@ } /* shift around the pwd variables, to make oldpwd and pwd relate to the - current (i.e. new) pwd */ + current (i.e. new) pwd */ zsfree(oldpwd); oldpwd = pwd; setjobpwd(); @@ -1064,7 +1064,7 @@ /* handle directory stack sizes out of range */ if (dirstacksize > 0) { int remove = countlinknodes(dirstack) - - (dirstacksize < 2 ? 2 : dirstacksize); + (dirstacksize < 2 ? 2 : dirstacksize); while (remove-- >= 0) zsfree(remnode(dirstack, lastnode(dirstack))); } @@ -1106,7 +1106,7 @@ #ifdef HAVE_SUPERROOT /* allow /.. segments to remain */ while (*src == '/' && src[1] == '.' && src[2] == '.' && - (!src[3] || src[3] == '/')) { + (!src[3] || src[3] == '/')) { *dest++ = '/'; *dest++ = '.'; *dest++ = '.'; @@ -1127,7 +1127,7 @@ src++; } /* if we are at the end of the input path, remove a trailing / (if it - exists), and return ct */ + exists), and return ct */ if (!*src) { while (dest > d0 + 1 && dest[-1] == '/') dest--; @@ -1293,7 +1293,7 @@ /* default values of first and last, and range checking */ if (first == -1) { first = ops['l']? addhistnum(curline.histnum,-16,0) - : addhistnum(curline.histnum,-1,0); + : addhistnum(curline.histnum,-1,0); } if (last == -1) last = ops['l']? addhistnum(curline.histnum,-1,0) : first; @@ -1319,8 +1319,8 @@ retval = 1; fil = gettempname(); if (((tempfd = open(fil, O_WRONLY | O_CREAT | O_EXCL | O_NOCTTY, 0600)) - == -1) || - ((out = fdopen(tempfd, "w")) == NULL)) { + == -1) || + ((out = fdopen(tempfd, "w")) == NULL)) { unqueue_signals(); zwarnnam("fc", "can't open temp file: %e", NULL, errno); } else { @@ -1397,7 +1397,7 @@ /* loop over occurences of oldstr in s, replacing them with newstr */ while ((newpos = (char *)strstr(oldpos, oldstr))) { newmem = (char *) zhalloc(1 + (newpos - s) - + strlen(newstr) + strlen(newpos + strlen(oldstr))); + + strlen(newstr) + strlen(newpos + strlen(oldstr))); ztrncpy(newmem, s, newpos - s); strcat(newmem, newstr); oldpos = newmem + strlen(newmem); @@ -1463,7 +1463,7 @@ ent->flags & HIST_FOREIGN? '*' : ' '); } /* output actual time (and possibly date) of execution of the - command, if required */ + command, if required */ if (d) { struct tm *ltm; ltm = localtime(&ent->stim); @@ -1569,7 +1569,7 @@ *s = '\0'; asg.value = s + 1; } else { - /* didn't find `=', so we only have a name */ + /* didn't find `=', so we only have a name */ asg.value = NULL; } return &asg; @@ -1624,8 +1624,8 @@ tc = 0; if (usepm || newspecial) { int chflags = ((off & pm->flags) | (on & ~pm->flags)) & - (PM_INTEGER|PM_EFLOAT|PM_FFLOAT|PM_HASHED| - PM_ARRAY|PM_TIED|PM_AUTOLOAD); + (PM_INTEGER|PM_EFLOAT|PM_FFLOAT|PM_HASHED| + PM_ARRAY|PM_TIED|PM_AUTOLOAD); /* keep the parameter if just switching between floating types */ if ((tc = chflags && chflags != (PM_EFLOAT|PM_FFLOAT))) usepm = 0; @@ -2220,7 +2220,7 @@ scanmatchtable(shfunctab, pprog, 0, DISABLED, shfunctab->printnode, pflags); } else { - /* apply the options to all functions matching the glob pattern */ + /* apply the options to all functions matching the glob pattern */ for (i = 0; i < shfunctab->hsize; i++) { for (shf = (Shfunc) shfunctab->nodes[i]; shf; shf = (Shfunc) shf->next) @@ -2330,7 +2330,7 @@ /* record pointer to next, since we may free this one */ next = (Param) pm->next; if ((!(pm->flags & PM_RESTRICTED) || - unset(RESTRICTED)) && + unset(RESTRICTED)) && pattry(pprog, pm->nam)) { unsetparam_pm(pm, 0, 1); match++; @@ -2823,7 +2823,7 @@ /* The argument is of the form foo=bar and we are not * * forcing a listing with -L, so define an alias */ aliastab->addnode(aliastab, ztrdup(asg->name), - createaliasnode(ztrdup(asg->value), flags1)); + createaliasnode(ztrdup(asg->value), flags1)); } else if ((a = (Alias) aliastab->getnode(aliastab, asg->name))) { /* display alias if appropriate */ if (!haveflags || @@ -2899,7 +2899,7 @@ unmetafy(args[n], &len[n]); else args[n] = getkeystring(args[n], &len[n], ops['b'] ? 2 : - (func != BIN_ECHO && !ops['e']), &nnl); + (func != BIN_ECHO && !ops['e']), &nnl); /* -P option -- interpret as a prompt sequence */ if(ops['P']) { /* @@ -2908,7 +2908,7 @@ * instead. */ char *str = unmetafy(promptexpand(metafy(args[n], len[n], - META_NOALLOC), 0, NULL, NULL), &len[n]); + META_NOALLOC), 0, NULL, NULL), &len[n]); args[n] = dupstring(str); free(str); } @@ -3029,9 +3029,11 @@ } while (*ap); fputc(ops['N'] ? '\0' : '\n', fout); } - if (fout != stdout) - fclose(fout); - return 0; + if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { + zwarnnam(name, "write error: %e", NULL, errno); + ret = 1; + } + return ret; } /* normal output */ for (; *args; args++, len++) { @@ -3041,9 +3043,11 @@ } if (!(ops['n'] || nnl)) fputc(ops['N'] ? '\0' : '\n', fout); - if (fout != stdout) - fclose(fout); - return 0; + if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { + zwarnnam(name, "write error: %e", NULL, errno); + ret = 1; + } + return ret; } /* shift builtin */ @@ -3152,7 +3156,7 @@ /* check for legality */ if(opch == ':' || !(p = memchr(optstr, opch, lenoptstr))) { p = "?"; -err: + err: zsfree(zoptarg); setsparam(var, ztrdup(p)); if(quiet) { @@ -3302,7 +3306,7 @@ } } if (in_exit++ && from_signal) - return; + return; if (isset(MONITOR)) { /* send SIGHUP to any jobs left running */ @@ -3630,9 +3634,9 @@ } /* All possible special types of input have been exhausted. Take one line, - and assign words to the parameters until they run out. Leftover words go - onto the last parameter. If an array is specified, all the words become - separate elements of the array. */ + and assign words to the parameters until they run out. Leftover words go + onto the last parameter. If an array is specified, all the words become + separate elements of the array. */ zbuforig = zbuf = (!ops['z']) ? NULL : (nonempty(bufstack)) ? (char *) getlinknode(bufstack) : ztrdup(""); @@ -3746,7 +3750,7 @@ for (;;) { c = zread(izle, &readchar); /* \ at the end of a line introduces a continuation line, except in - raw mode (-r option) */ + raw mode (-r option) */ if (bslash && c == '\n') { bslash = 0; continue; @@ -3823,8 +3827,8 @@ /* use zbuf if possible */ if (zbuf) { /* If zbuf points to anything, it points to the next character in the - buffer. This may be a null byte to indicate EOF. If reading from the - buffer, move on the buffer pointer. */ + buffer. This may be a null byte to indicate EOF. If reading from the + buffer, move on the buffer pointer. */ if (*zbuf == Meta) return zbuf++, STOUC(*zbuf++ ^ 32); else @@ -3846,21 +3850,21 @@ #if defined(EAGAIN) || defined(EWOULDBLOCK) if (!retry && readfd == 0 && ( # ifdef EAGAIN - errno == EAGAIN + errno == EAGAIN # ifdef EWOULDBLOCK - || + || # endif /* EWOULDBLOCK */ # endif /* EAGAIN */ # ifdef EWOULDBLOCK - errno == EWOULDBLOCK + errno == EWOULDBLOCK # endif /* EWOULDBLOCK */ ) && setblock_stdin()) { retry = 1; continue; } else #endif /* EAGAIN || EWOULDBLOCK */ - if (errno == EINTR && !(errflag || retflag || breaks || contflag)) - continue; + if (errno == EINTR && !(errflag || retflag || breaks || contflag)) + continue; break; } return EOF; @@ -4132,10 +4136,10 @@ int whomask, umaskop, mask; /* More than one symbolic argument may be used at once, each separated - by commas. */ + by commas. */ for (;;) { /* First part of the argument -- who does this apply to? - u=owner, g=group, o=other. */ + u=owner, g=group, o=other. */ whomask = 0; while (*s == 'u' || *s == 'g' || *s == 'o' || *s == 'a') if (*s == 'u') ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tbm@cyrius.com: Bug#130817: zsh's echo doesn't error if device is full] 2002-01-27 23:06 ` Clint Adams @ 2002-01-27 23:23 ` Clint Adams 0 siblings, 0 replies; 5+ messages in thread From: Clint Adams @ 2002-01-27 23:23 UTC (permalink / raw) To: zsh-workers > Here's the "backport" for 4.0.x: And this might help too. Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.46.4.5 diff -u -r1.46.4.5 builtin.c --- Src/builtin.c 2002/01/27 23:09:24 1.46.4.5 +++ Src/builtin.c 2002/01/27 23:22:01 @@ -2869,7 +2869,7 @@ int bin_print(char *name, char **args, char *ops, int func) { - int nnl = 0, fd, argc, n; + int nnl = 0, fd, argc, n, ret = 0; int *len; Histent ent; FILE *fout = stdout; ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-01-27 23:23 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-01-27 20:21 [tbm@cyrius.com: Bug#130817: zsh's echo doesn't error if device is full] Clint Adams 2002-01-27 21:46 ` Bart Schaefer 2002-01-27 22:42 ` Clint Adams 2002-01-27 23:06 ` Clint Adams 2002-01-27 23:23 ` Clint Adams
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).