search for: sh_error

Displaying 12 results from an estimated 12 matches for "sh_error".

2007 Aug 23
0
[git patch] klibc dash 0.5.4 update
...49a2972..7f99d4a 100644 --- a/usr/dash/input.c +++ b/usr/dash/input.c @@ -428,7 +428,6 @@ int setinputfile(const char *fname, int flags) { int fd; - int fd2; INTOFF; if ((fd = open(fname, O_RDONLY)) < 0) { @@ -436,11 +435,8 @@ setinputfile(const char *fname, int flags) goto out; sh_error("Can't open %s", fname); } - if (fd < 10) { - fd2 = copyfd(fd, 10); - close(fd); - fd = fd2; - } + if (fd < 10) + fd = savefd(fd); setinputfd(fd, flags & INPUT_PUSH_FILE); out: INTON; diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c index 77ed779..7e38048 100644 ---...
2012 Jul 02
0
[klibc:master] [EVAL] Remove unused EV_BACKCMD flag
...= ifsfirst; - savelastp = ifslastp; - saveargbackq = argbackq; - - exitstatus = oexitstatus; - evalcommand(n, EV_BACKCMD, result); - - ifsfirst = saveifs; - ifslastp = savelastp; - argbackq = saveargbackq; - } else -#endif - { - int pip[2]; - struct job *jp; - - if (pipe(pip) < 0) - sh_error("Pipe call failed"); - jp = makejob(n, 1); - if (forkshell(jp, n, FORK_NOJOB) == 0) { - FORCEINTON; - close(pip[0]); - if (pip[1] != 1) { - dup2(pip[1], 1); - close(pip[1]); - } - ifsfree(); - evaltreenr(n, EV_EXIT); - /* NOTREACHED */ + if (pipe(pip) < 0) + sh_e...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Do not reprocess data when expanding words
...- * efficiency. Next we scan backwards looking for the - * start of arithmetic. - */ - start = stackblock(); - p = expdest; - pushstackmark(&sm, p - start); - *--p = '\0'; - p--; - do { - int esc; - - while (*p != (char)CTLARI) { - p--; -#ifdef DEBUG - if (p < start) { - sh_error("missing CTLARI (shouldn't happen)"); - } -#endif - } - - esc = esclen(start, p); - if (!(esc % 2)) { - break; - } + p = stackblock(); + begoff = expdest - p; + p = argstr(start, flag & EXP_DISCARD); - p -= esc + 1; - } while (1); + if (flag & EXP_DISCARD) + goto o...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Add vfork support
...;prev_job) freejob(jp); } -STATIC inline void -forkparent(struct job *jp, union node *n, int mode, pid_t pid) +static void forkparent(struct job *jp, union node *n, int mode, pid_t pid) { + if (pid < 0) { + TRACE(("Fork failed, errno=%d", errno)); + if (jp) + freejob(jp); + sh_error("Cannot fork"); + /* NOTREACHED */ + } + TRACE(("In parent shell: child = %d\n", pid)); if (!jp) return; @@ -925,19 +951,40 @@ forkshell(struct job *jp, union node *n, int mode) TRACE(("forkshell(%%%d, %p, %d) called\n", jobno(jp), n, mode)); pid = fork(...
2020 Mar 28
0
[klibc:update-dash] dash: memalloc: Avoid looping in growstackto
...dash/memalloc.c +++ b/usr/dash/memalloc.c @@ -201,16 +201,16 @@ popstackmark(struct stackmark *mark) * part of the block that has been used. */ -void -growstackblock(void) +static void growstackblock(size_t min) { size_t newlen; newlen = stacknleft * 2; if (newlen < stacknleft) sh_error("Out of space"); - if (newlen < 128) - newlen += 128; + min = SHELL_ALIGN(min | 128); + if (newlen < min) + newlen += min; if (stacknxt == stackp->space && stackp != &stackbase) { struct stack_block *sp; @@ -261,15 +261,15 @@ void * growstackstr(void) { s...
2012 Jul 02
0
[klibc:master] [MEMALLOC] Avoid gcc warning: variable ' oldstackp' set but not used
...tions(-) diff --git a/usr/dash/memalloc.c b/usr/dash/memalloc.c index e75e609..9fea067 100644 --- a/usr/dash/memalloc.c +++ b/usr/dash/memalloc.c @@ -206,20 +206,18 @@ growstackblock(void) { size_t newlen; - newlen = stacknleft * 2; + newlen = stacknleft * 2; if (newlen < stacknleft) sh_error("Out of space"); if (newlen < 128) newlen += 128; if (stacknxt == stackp->space && stackp != &stackbase) { - struct stack_block *oldstackp; struct stack_block *sp; struct stack_block *prevstackp; size_t grosslen; INTOFF; - oldstackp = stackp;...
2012 Oct 01
0
[klibc:master] Avoid overflow for very long variable name
...ot;) at output.c:257 #2 0x000000000040382e in exvwarning2 (msg=0x417339 "Out of space", ap=0x7fffffffd468) at error.c:125 #3 0x000000000040387e in exverror (cond=1, msg=0x417339 "Out of space", ap=0x7fffffffd468) at error.c:156 #4 0x0000000000403938 in sh_error (msg=0x417339 "Out of space") at error.c:172 #5 0x000000000040c970 in ckmalloc (nbytes=18446744071562067984) at memalloc.c:57 #6 0x000000000040ca78 in stalloc (nbytes=18446744071562067972) at memalloc.c:132 #7 0x000000000040ece9 in grabstackblock (len=1844674407156206...
2019 Jan 25
0
[klibc:update-dash] [CD] support drive letters on Cygwin
...ygwin, thanks to drive letters, some absolute paths do + not begin with slash; but cygwin includes a function that + forces normalization to the posix form */ + char pathbuf[PATH_MAX]; + if (cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE, dir, pathbuf, + sizeof(pathbuf)) < 0) + sh_error("can't normalize %s", dir); + dir = pathbuf; +#endif + cdcomppath = sstrdup(dir); STARTSTACKSTR(new); if (*dir != '/') {
2020 Mar 28
0
[klibc:update-dash] dash: [CD] support drive letters on Cygwin
...ygwin, thanks to drive letters, some absolute paths do + not begin with slash; but cygwin includes a function that + forces normalization to the posix form */ + char pathbuf[PATH_MAX]; + if (cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE, dir, pathbuf, + sizeof(pathbuf)) < 0) + sh_error("can't normalize %s", dir); + dir = pathbuf; +#endif + cdcomppath = sstrdup(dir); STARTSTACKSTR(new); if (*dir != '/') {
2020 Mar 28
0
[klibc:update-dash] dash: eval: Reset handler when entering a subshell
.../* never returns */ @@ -574,6 +576,7 @@ evalpipe(union node *n, int flags) } } if (forkshell(jp, lp->n, n->npipe.backgnd) == 0) { + reset_handler(); INTON; if (pip[1] >= 0) { close(pip[0]); @@ -630,6 +633,7 @@ evalbackcmd(union node *n, struct backcmd *result) sh_error("Pipe call failed"); jp = makejob(n, 1); if (forkshell(jp, n, FORK_NOJOB) == 0) { + reset_handler(); FORCEINTON; close(pip[0]); if (pip[1] != 1) { diff --git a/usr/dash/main.c b/usr/dash/main.c index 6b3a0909..b2712cbd 100644 --- a/usr/dash/main.c +++ b/usr/dash/main.c @@ -7...
2019 Jan 25
0
[klibc:update-dash] [BUILTIN] Handle embedded NULs correctly in printf
...@@ -283,35 +284,58 @@ fmtstr(char *outbuf, size_t length, const char *fmt, ...) } +static int xvasprintf(char **sp, size_t size, const char *f, va_list ap) +{ + char *s; + int len; + va_list ap2; + + va_copy(ap2, ap); + len = xvsnprintf(*sp, size, f, ap2); + va_end(ap2); + if (len < 0) + sh_error("xvsnprintf failed"); + if (len < size) + return len; + + s = stalloc((len >= stackblocksize() ? len : stackblocksize()) + 1); + *sp = s; + len = xvsnprintf(s, len + 1, f, ap); + return len; +} + + +int xasprintf(char **sp, const char *f, ...) +{ + va_list ap; + int ret; + + va_sta...
2020 Mar 28
0
[klibc:update-dash] dash: [BUILTIN] Handle embedded NULs correctly in printf
...@@ -283,35 +284,58 @@ fmtstr(char *outbuf, size_t length, const char *fmt, ...) } +static int xvasprintf(char **sp, size_t size, const char *f, va_list ap) +{ + char *s; + int len; + va_list ap2; + + va_copy(ap2, ap); + len = xvsnprintf(*sp, size, f, ap2); + va_end(ap2); + if (len < 0) + sh_error("xvsnprintf failed"); + if (len < size) + return len; + + s = stalloc((len >= stackblocksize() ? len : stackblocksize()) + 1); + *sp = s; + len = xvsnprintf(s, len + 1, f, ap); + return len; +} + + +int xasprintf(char **sp, const char *f, ...) +{ + va_list ap; + int ret; + + va_sta...