diff -Paur --no-dereference -- dash.upstream/src/cd.c dash/src/cd.c --- dash.upstream/src/cd.c +++ dash/src/cd.c @@ -268,7 +268,7 @@ STATIC char * getpwd() { -#ifdef __GLIBC__ +#if defined(__GLIBC__) || defined(__sortix__) char *dir = getcwd(0, 0); if (dir) diff -Paur --no-dereference -- dash.upstream/src/exec.c dash/src/exec.c --- dash.upstream/src/exec.c +++ dash/src/exec.c @@ -151,6 +151,9 @@ STATIC void tryexec(char *cmd, char **argv, char **envp) { +#if defined(__sortix__) + execvpe((const char*) cmd, argv, envp); +#else char *const path_bshell = _PATH_BSHELL; repeat: @@ -166,6 +169,7 @@ *argv = cmd = path_bshell; goto repeat; } +#endif } static const char *legal_pathopt(const char *opt, const char *term, int magic) diff -Paur --no-dereference -- dash.upstream/src/expand.c dash/src/expand.c --- dash.upstream/src/expand.c +++ dash/src/expand.c @@ -44,6 +44,13 @@ #include #include #include +/* PATCH: Sortix does not currently have maximum filename or path length */ +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif +#ifndef NAME_MAX +#define NAME_MAX 255 +#endif #include #ifdef HAVE_FNMATCH #include diff -Paur --no-dereference -- dash.upstream/src/histedit.c dash/src/histedit.c --- dash.upstream/src/histedit.c +++ dash/src/histedit.c @@ -32,7 +32,6 @@ * SUCH DAMAGE. */ -#include #ifdef HAVE_PATHS_H #include #endif diff -Paur --no-dereference -- dash.upstream/src/jobs.c dash/src/jobs.c --- dash.upstream/src/jobs.c +++ dash/src/jobs.c @@ -40,7 +40,6 @@ #include #endif #include -#include #ifdef BSD #include #include @@ -212,7 +211,7 @@ mflag = on = 0; goto close; } - if (pgrp == getpgrp()) + if (pgrp == getpgid(0)) break; killpg(0, SIGTTIN); } while (1); @@ -461,7 +460,7 @@ if (mode & SHOW_PGID) { /* just output process (group) id of pipeline */ - outfmt(out, "%d\n", ps->pid); + outfmt(out, "%jd\n", (intmax_t) ps->pid); return; } @@ -474,7 +473,7 @@ s[col - 2] = '-'; if (mode & SHOW_PID) - col += fmtstr(s + col, 16, "%d ", ps->pid); + col += fmtstr(s + col, 16, "%jd ", (intmax_t) ps->pid); psend = ps + jp->nprocs; @@ -494,7 +493,7 @@ do { /* for each process */ - col = fmtstr(s, 48, " |\n%*c%d ", indent, ' ', ps->pid) - 3; + col = fmtstr(s, 48, " |\n%*c%jd ", indent, ' ', (intmax_t) ps->pid) - 3; start: outfmt( @@ -971,7 +970,7 @@ sigblockall(NULL); vforked++; - pid = vfork(); + pid = fork(); if (!pid) { forkchild(jp, n, FORK_FG); @@ -1179,7 +1178,7 @@ do { gotsigchld = 0; do - err = wait3(status, flags, NULL); + err = waitpid(-1, status, flags); while (err < 0 && errno == EINTR); if (err || (err = -!block)) diff -Paur --no-dereference -- dash.upstream/src/Makefile.in dash/src/Makefile.in --- dash.upstream/src/Makefile.in +++ dash/src/Makefile.in @@ -669,12 +669,14 @@ -rm -f ./$(DEPDIR)/alias.Po -rm -f ./$(DEPDIR)/arith_yacc.Po -rm -f ./$(DEPDIR)/arith_yylex.Po + -rm -f ./$(DEPDIR)/builtins.Po -rm -f ./$(DEPDIR)/cd.Po -rm -f ./$(DEPDIR)/error.Po -rm -f ./$(DEPDIR)/eval.Po -rm -f ./$(DEPDIR)/exec.Po -rm -f ./$(DEPDIR)/expand.Po -rm -f ./$(DEPDIR)/histedit.Po + -rm -f ./$(DEPDIR)/init.Po -rm -f ./$(DEPDIR)/input.Po -rm -f ./$(DEPDIR)/jobs.Po -rm -f ./$(DEPDIR)/mail.Po @@ -682,11 +684,14 @@ -rm -f ./$(DEPDIR)/memalloc.Po -rm -f ./$(DEPDIR)/miscbltin.Po -rm -f ./$(DEPDIR)/mystring.Po + -rm -f ./$(DEPDIR)/nodes.Po -rm -f ./$(DEPDIR)/options.Po -rm -f ./$(DEPDIR)/output.Po -rm -f ./$(DEPDIR)/parser.Po -rm -f ./$(DEPDIR)/redir.Po -rm -f ./$(DEPDIR)/show.Po + -rm -f ./$(DEPDIR)/signames.Po + -rm -f ./$(DEPDIR)/syntax.Po -rm -f ./$(DEPDIR)/system.Po -rm -f ./$(DEPDIR)/trap.Po -rm -f ./$(DEPDIR)/var.Po diff -Paur --no-dereference -- dash.upstream/src/miscbltin.c dash/src/miscbltin.c --- dash.upstream/src/miscbltin.c +++ dash/src/miscbltin.c @@ -37,7 +37,6 @@ */ #include /* quad_t */ -#include /* BSD4_4 */ #include #include #include diff -Paur --no-dereference -- dash.upstream/src/output.c dash/src/output.c --- dash.upstream/src/output.c +++ dash/src/output.c @@ -44,7 +44,6 @@ */ #include /* quad_t */ -#include /* BSD4_4 */ #include #include /* defines BUFSIZ */ diff -Paur --no-dereference -- dash.upstream/src/parser.c dash/src/parser.c --- dash.upstream/src/parser.c +++ dash/src/parser.c @@ -32,10 +32,7 @@ * SUCH DAMAGE. */ -#if HAVE_ALLOCA_H #include -#endif - #include #include "shell.h" @@ -1137,10 +1134,12 @@ if (len) { char *str; - str = alloca(len + 1); + str = ckmalloc(len + 1); *(char *)mempcpy(str, p, len) = 0; pushstring(str, NULL); + + ckfree(str); } } } @@ -1373,7 +1372,7 @@ str = NULL; savelen = out - (char *)stackblock(); if (savelen > 0) { - str = alloca(savelen); + str = ckmalloc(savelen); memcpy(str, stackblock(), savelen); } if (oldstyle) { @@ -1463,6 +1462,7 @@ if (str) { memcpy(out, str, savelen); STADJUST(savelen, out); + ckfree(str); } USTPUTC(CTLBACKQ, out); if (oldstyle) diff -Paur --no-dereference -- dash.upstream/src/redir.c dash/src/redir.c --- dash.upstream/src/redir.c +++ dash/src/redir.c @@ -34,7 +34,6 @@ #include #include -#include /* PIPE_BUF */ #include #include #include diff -Paur --no-dereference -- dash.upstream/src/shell.h dash/src/shell.h --- dash.upstream/src/shell.h +++ dash/src/shell.h @@ -49,8 +49,6 @@ * a quit signal will generate a core dump. */ -#include - #ifndef JOBS #define JOBS 1 #endif