rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit d884971193ef4934424b77ae862e8b0ecf70bab3
parent 77b18786228a8cf9f58aee09677440c61dc218a9
Author: Toby Goodwin <tjg@star.le.ac.uk>
Date:   Wed, 13 Aug 2003 13:51:14 +0100

release: rc-1.7.1

Diffstat:
MChangeLog | 42++++++++++++++++++++++++++++++++++++++++++
MINSTALL | 30++++++------------------------
MMakefile.am | 10+++++-----
MNEWS | 33++++++++++++++-------------------
MREADME | 4++--
Macinclude.m4 | 33+++++++++------------------------
Mconfigure.ac | 53++++++++++++++++++++++++++---------------------------
Mglob.c | 6+++---
Mhistory.c | 24++++++++++++------------
Minput.c | 4+++-
Mnalloc.c | 4+++-
Mrc.1 | 21++++++++++++---------
Mrc.h | 2+-
Msignal.c | 15+++++++++++----
Astat.h | 6++++++
Mtrip.rc | 18+++++++-----------
Mtripping.c | 18------------------
Mvar.c | 1+
Mwhich.c | 14+++++++-------
19 files changed, 170 insertions(+), 168 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -788,3 +788,45 @@ Changes since rc-1.5b2 2002-06-18 Release: rc-1.7. + +2002-07-25 + + Bug: fix globbing of broken symlinks. + +2002-07-31 + + Bug: readline doesn't handle EIO either. + +2002-08-15 + + Bug: variables that are sometimes exported (i.e. $prompt and + $version) need to be made exportable if they are inherited from the + environment. + + Portability: don't call sigaction() for SIGKILL or SIGSTOP; don't + hand a garbage signal mask to sigaction() (thanks Jeremy + Fitzhardinge). Also, remove use of SA_INTERRUPT (SUSv3, BSD, + etc. have SA_RESTART with the inverted meaning). + +2002-08-20 + + Bug: don't call ealloc(0) on systems where getgroups() doesn't + return egid (thanks Chris Siebenmann). + +2002-11-27 + + Bug: history dumps core if more colons than substitutions (thanks + Callum Gibson); history fails to avoid itself if it's the only + command; history writes and reads outside allocated memory. + + Configuration: upgrade to autoconf-2.56 and automake-1.7.1. + +2003-07-17 + + Testing: remove test for large file support, as it causes + indigestion on file systems that don't support sparse files (thanks + Scott Schwartz). + +2003-07-22 + + Release: rc-1.7.1. diff --git a/INSTALL b/INSTALL @@ -33,13 +33,13 @@ descending order of usefulness. --with-editline This option tells rc to use the editline package (see the web page - for details) to provide EMACS style command line editing and history. - If the editline library is not installed in a standard place, you can - tell configure where to find it by setting the environment variable - LDFLAGS. For example, the maintainer builds rc by copying libedit.a - into the rc build directory and then running this configure command. + for details) to provide EMACS style command line editing and + history. If the editline library is not installed in a standard + place, you can tell configure where to find it by setting the + environment variable LDFLAGS. For example, you might copy libedit.a + into the rc source directory and then run this configure command. - LDFLAGS=-L. sh ../rc-1.5b3/configure --with-editline + LDFLAGS=-L. sh configure --with-editline --with-vrl @@ -141,24 +141,6 @@ implement Unix semantics (specifically permissions bits). This means that `make trip' is not useful under CygWin, for instance. -LARGE FILE SUPPORT - -This release of rc supports large files (i.e. with 64 bit offsets), on -systems where the configure script can figure out how to enable this. -When you run `make trip' (you always run `make trip', right?) the -penultimate line of output (before "trip complete") reports whether -large file support seems to be working or not. - -Large file support is a function of file systems, as well as -applications. For example, NFS and tmpfs file systems often do not -support large files. The test used by `make trip' is therefore -subject to false negatives. That is, a report that "large file -support seems NOT to be working" may be erroneous. To minimise this -possibility, the test is performed both in the current directory -(where you built rc) and /tmp. (I don't think there's any scenario -where a false positive can be reported.) - - BUILDING IN ANOTHER DIRECTORY If you have a suitable `make', you can build rc in a different directory diff --git a/Makefile.am b/Makefile.am @@ -1,9 +1,5 @@ ## Process this file with automake to produce Makefile.in -if AMC_ADDON -ADDON = @ADDON@ -endif - if AMC_HISTORY man_MANS = rc.1 history.1 HISTORY = history @@ -35,7 +31,7 @@ EXTRA_rc_SOURCES = addon.c execve.c readline.c system.c system-bsd.c rc_DEPENDENCIES = sigmsgs.o $(ADDON) $(EXECVE) $(READLINE) $(SYSTEM) rc_LDADD = sigmsgs.o $(ADDON) $(EXECVE) $(READLINE) $(SYSTEM) -noinst_HEADERS = getgroups.h jbwrap.h parse.h proto.h rc.h rlimit.h wait.h +noinst_HEADERS = getgroups.h jbwrap.h parse.h proto.h rc.h rlimit.h stat.h wait.h BUILT_SOURCES = sigmsgs.c @@ -44,6 +40,10 @@ EXTRA_DIST = EXAMPLES RELDATE addon.c addon.h history.1 parse.y rc.1 trip.rc sigmsgs.c sigmsgs.h: mksignal ./mksignal +# Newer automake's buildtime dependency tracking can't seem to figure +# this one out. +status.o: statval.h + statval.h: mkstatval ./mkstatval > statval.h diff --git a/NEWS b/NEWS @@ -1,25 +1,20 @@ -Highlights of changes since rc-1.6. See ChangeLog for further details. +Highlights of changes since rc-1.7. See ChangeLog for further details. -Portability. Many minor tweaks, including fixes for BeOS, CygWin, -QNX, and gcc-3. +Portability. A fix to the autoconfiguration means that the nasty +longjmp() code is now omitted for all modern Unix systems; previously +rc only did the Right Thing on Linux. The test for large files in +trip.rc was removed, as this causes indigestion on file systems that +don't support sparse files (the configuration and implementation of +large file support is still present of course). -Bug fixes. A number of bugs have been fixed. The serious ones were: -a core dump, triggered by `~ () '*''; premature exit, triggered by -sourcing a file which could be open()ed but not read() (such as a -directory on many systems); uninterruptible looping, triggered by -semantic errors in `fn prompt'; deficiencies in the `limit' builtin. +Bug fixes. Broken symlinks now glob correctly. The variables $prompt +and $version are now exported if they are inherited from the +environment when rc starts. EIO handling is now enabled for readline +too. A few bogosities in the history program were fixed. -New features. The following features are new: the `$version' variable -replaces the `-V' flag; the `-I' flag (definitively not interactive) -was added for compatibility with the Plan 9 rc; ASCII SOH (^A) is now -handled transparently; support for large files; support for more -process resource limits. +New features. None - this is a bugfix release. -Documentation. Distributions of this rc used to include a PostScript -paper given by Tom Duff to the UKUUG, describing the Plan 9 rc. This -paper is no longer distributed with rc, but instead is available on -the web, both in its original PostScript version, and an updated HTML -version. +Documentation. Minor updates only. Tim Goodwin -2002-05-21 +2003-07-17 diff --git a/README b/README @@ -1,8 +1,8 @@ -This is release rc-1.7. +This is release rc-1.7.1. See COPYING for copying information. All files are - Copyright 1991, 2001, 2002 Byron Rakitzis. + Copyright 1991, 2001, 2002, 2003 Byron Rakitzis. See INSTALL for build and installation information. diff --git a/acinclude.m4 b/acinclude.m4 @@ -9,7 +9,7 @@ int main(void) { } ], rc_cv_func_posix_getgroups=yes, rc_cv_func_posix_getgroups=no, rc_cv_func_posix_getgroups=yes)) case "$rc_cv_func_posix_getgroups" in - yes) AC_DEFINE(HAVE_POSIX_GETGROUPS) ;; + yes) AC_DEFINE(HAVE_POSIX_GETGROUPS, 1, [Define to 1 if you have the `getgroups' function with POSIX semantics.]) ;; esac ]) @@ -25,7 +25,7 @@ sigjmp_buf e; sigsetjmp(e, 1); ], rc_cv_sigsetjmp=yes, rc_cv_sigsetjmp=no)) case "$rc_cv_sigsetjmp" in - yes) AC_DEFINE(HAVE_SIGSETJMP) ;; + yes) AC_DEFINE(HAVE_SIGSETJMP, 1, [Define to 1 if you have the `sigsetjmp' function or macro.]) ;; esac ]) @@ -38,7 +38,7 @@ AC_DEFUN(RC_FUNC_STRERROR, [ strerror(0); ], rc_cv_strerror=yes, rc_cv_strerror=no)) case "$rc_cv_strerror" in - yes) AC_DEFINE(HAVE_STRERROR) ;; + yes) AC_DEFINE(HAVE_STRERROR, 1, [Define to 1 if you have the `strerror' function or macro.]) ;; esac ]) @@ -61,7 +61,7 @@ int f; f = RLIMIT_DATA; ], rc_cv_kernel_rlimit=yes, rc_cv_kernel_rlimit=no)])) case "$rc_cv_kernel_rlimit" in - yes) AC_DEFINE(RLIMIT_NEEDS_KERNEL) ;; + yes) AC_DEFINE(RLIMIT_NEEDS_KERNEL, 1, [Define to 1 if `_KERNEL' must be defined for `RLIMIT_*' macros.]) ;; esac ]) @@ -77,7 +77,7 @@ AC_DEFUN(RC_TYPE_RLIM_T, [ ], rc_cv_have_rlim_t=yes, rc_cv_have_rlim_t=no)) case "$rc_cv_have_rlim_t" in - yes) AC_DEFINE(HAVE_RLIM_T) ;; + yes) AC_DEFINE(HAVE_RLIM_T, 1, [Define to 1 if you have the `rlim_t' type.]) ;; no) AC_CACHE_CHECK(for native quad_t, rc_cv_have_quad_t, AC_TRY_COMPILE([ #include <sys/types.h> @@ -88,7 +88,7 @@ a = (quad_t)0; ], rc_cv_have_quad_t=yes, rc_cv_have_quad_t=no)) case "$rc_cv_have_quad_t" in - yes) AC_DEFINE(HAVE_QUAD_T) + yes) AC_DEFINE(HAVE_QUAD_T, 1, [Define to 1 if you have the `quad_t' type.]) AC_CACHE_CHECK(if rlimit values are quad_t, rc_cv_rlim_t_is_quad_t, AC_TRY_RUN([ #include <sys/types.h> @@ -108,7 +108,7 @@ main(){ ], rc_cv_rlim_t_is_quad_t=yes, rc_cv_rlim_t_is_quad_t=no, $ac_cv_type_quad_t)) case "$rc_cv_rlim_t_is_quad_t" in - yes) AC_DEFINE(RLIM_T_IS_QUAD_T) ;; + yes) AC_DEFINE(RLIM_T_IS_QUAD_T, 1, [Define to 1 if `rlim_t' is `quad_t'.]) ;; esac ;; esac @@ -123,26 +123,11 @@ AC_DEFUN(RC_TYPE_SIG_ATOMIC_T, [ AC_EGREP_HEADER(sig_atomic_t, signal.h, rc_cv_sig_atomic_t=yes, rc_cv_sig_atomic_t=no)) case "$rc_cv_sig_atomic_t" in - no) AC_DEFINE(sig_atomic_t, int) ;; + no) AC_DEFINE(sig_atomic_t, int, [Define to 1 if you have the `sig_atomic_t' type.]) ;; esac ]) -dnl Check for sigaction and SA_INTERRUPT -AC_DEFUN(RC_FUNC_SIGACTION, [ - AC_CACHE_CHECK(for sigaction and SA_INTERRUPT, rc_cv_sa_int, - AC_TRY_COMPILE([ -#include <signal.h> - ], [ -struct sigaction foo; -foo.sa_flags = SA_INTERRUPT; -sigaction(SIGINT, 0, 0); - ], rc_cv_sa_int=yes, rc_cv_sa_int=no - ) - ) -]) - - dnl Do we have SysV SIGCLD semantics? In other words, if we set the dnl action for SIGCLD to SIG_IGN does wait() always say ECHILD? Linux, dnl of course, is bizarre here. It basically implements the SysV @@ -174,7 +159,7 @@ int main(void) { } ], rc_cv_sysv_sigcld=yes, rc_cv_sysv_sigcld=no, rc_cv_sysv_sigcld=yes)) case "$rc_cv_sysv_sigcld" in - yes) AC_DEFINE(HAVE_SYSV_SIGCLD) ;; + yes) AC_DEFINE(HAVE_SYSV_SIGCLD, 1, [Has SysV SIGCLD]) ;; esac ]) diff --git a/configure.ac b/configure.ac @@ -2,13 +2,13 @@ dnl Get things going... AC_INIT(rc.h) RELDATE=`cat $srcdir/RELDATE` -AC_DEFINE_UNQUOTED(RELDATE, "$RELDATE") +AC_DEFINE_UNQUOTED(RELDATE, "$RELDATE", [Release date]) dnl Automake stuff. dnl Use this one for snapshots... -dnl AM_INIT_AUTOMAKE(rc, 1.6s`echo $RELDATE |sed 's/-//g'`) +dnl AM_INIT_AUTOMAKE(rc, 1.7s`echo $RELDATE |sed 's/-//g'`) dnl ...and this one for releases -AM_INIT_AUTOMAKE(rc, 1.7) +AM_INIT_AUTOMAKE(rc, 1.7.1) AM_CONFIG_HEADER(config.h) @@ -40,7 +40,16 @@ AC_TYPE_SIZE_T AC_TYPE_UID_T AC_CHECK_TYPE(ssize_t, long) -AC_CHECK_FUNCS(getgroups setpgrp setrlimit) +AC_CHECK_FUNCS(getgroups lstat setpgrp setrlimit sigaction) + +dnl We prefer system calls that don't restart. If we have sigaction() +dnl we'll use it. Otherwise, we check whether good ol' signal() +dnl produces interruptible system calls. +case "$ac_cv_func_sigaction" in +no) AC_SYS_RESTARTABLE_SYSCALLS ;; +esac +AM_CONDITIONAL(AMC_RESTART, test "$ac_cv_sys_restartable_syscalls" = yes) + RC_FUNC_GETGROUPS RC_FUNC_SIGSETJMP @@ -55,22 +64,12 @@ RC_TYPE_RLIM_T RC_TYPE_SIG_ATOMIC_T -dnl We prefer system calls that don't restart. If we have sigaction() -dnl and SA_INTERRUPT, we'll use 'em. Otherwise, we check whether good -dnl ol' signal() produces interruptible system calls. -RC_FUNC_SIGACTION -case "$rc_cv_sa_int" in -yes) AC_DEFINE(HAVE_SA_INTERRUPT) ;; -no) AC_SYS_RESTARTABLE_SYSCALLS ;; -esac -AM_CONDITIONAL(AMC_RESTART, test "$ac_cv_sys_restartable_syscalls" = yes) - RC_SYS_V_SIGCLD dnl Does the kernel handle `#! /interpreter'? AC_SYS_INTERPRETER case "$ac_cv_sys_interpreter" in -yes) AC_DEFINE(HASH_BANG) ;; +yes) AC_DEFINE(HASH_BANG, 1, [Define to 1 if your kernel understands `#!' magic numbers]) ;; esac AM_CONDITIONAL(AMC_NO_HASHBANG, test "$ac_cv_sys_interpreter" = no) @@ -80,27 +79,27 @@ dnl /proc/self/fd. Failing that, we'll try for POSIX mkfifo(), or a dnl mknod() that makes FIFOs. RC_SYS_DEV_FD case "$rc_cv_sys_dev_fd" in -yes) AC_DEFINE(HAVE_DEV_FD) ;; -odd) AC_DEFINE(HAVE_PROC_SELF_FD) ;; +yes) AC_DEFINE(HAVE_DEV_FD, 1, [Define to 1 if you have /dev/fd.]) ;; +odd) AC_DEFINE(HAVE_PROC_SELF_FD, 1, [Define to 1 if you have /proc/self/fd.]) ;; no) AC_CHECK_FUNCS(mkfifo) ;; esac case "$ac_cv_func_mkfifo" in -yes) AC_DEFINE(HAVE_FIFO) ;; +yes) AC_DEFINE(HAVE_FIFO, 1, [Define to 1 if you have the `mkfifo' function.]) ;; no) RC_SYS_MKNOD_FIFO ;; esac dnl Now handle arguments. AC_ARG_ENABLE(builtin-echo, [ --disable-builtin-echo Don't include \`echo' as a builtin], - test "x$enableval" != "xno" && AC_DEFINE(RC_ECHO), + test "x$enableval" != "xno" && AC_DEFINE(RC_ECHO, 1, [Define to 1 to include `echo' as a builtin.]), AC_DEFINE(RC_ECHO)) AC_ARG_ENABLE(job, [ --disable-job Don't do job-control-style backgrounding], - test "x$enableval" != "xno" && AC_DEFINE(RC_JOB), + test "x$enableval" != "xno" && AC_DEFINE(RC_JOB, 1, [Define to 1 to use job-control-style backgrounding.]), AC_DEFINE(RC_JOB)) AC_ARG_ENABLE(protect-env, [ --disable-protect-env Don't protect environment names], - test "x$enableval" != "xno" && AC_DEFINE(PROTECT_ENV), + test "x$enableval" != "xno" && AC_DEFINE(PROTECT_ENV, 1, [Define to 1 to encode exported environment names.]), AC_DEFINE(PROTECT_ENV)) AC_ARG_ENABLE(def-interp, @@ -111,7 +110,7 @@ AC_ARG_ENABLE(def-interp, no) ;; yes) - AC_DEFINE(DEFAULTINTERP, "/bin/sh") + AC_DEFINE(DEFAULTINTERP, "/bin/sh", [The default interpreter]) ;; *) AC_DEFINE_UNQUOTED(DEFAULTINTERP, "$enableval") @@ -126,7 +125,7 @@ AC_ARG_ENABLE(def-path, [ case "$enableval" in no|yes) ;; - *) AC_DEFINE_UNQUOTED(DEFAULTPATH, $enableval) ;; + *) AC_DEFINE_UNQUOTED(DEFAULTPATH, $enableval, [The default path]) ;; esac ], enable_def_path=yes) @@ -166,14 +165,14 @@ AC_ARG_WITH(addon, [ --with-addon[=foo.c] Extra builtins, from addon.c by de ]) AM_CONDITIONAL(AMC_ADDON, test "$ADDON" != "") case "$ADDON" in -?*) AC_DEFINE(RC_ADDON) ;; +?*) AC_DEFINE(RC_ADDON, 1, [Define to 1 to use addon functions.]) ;; esac AC_SUBST(ADDON) AC_ARG_WITH(editline, [ --with-editline Simmule Turner's line editing], AC_CHECK_LIB(edit, readline, - AC_DEFINE(EDITLINE) LIBS="$LIBS -ledit", + AC_DEFINE(EDITLINE, 1, [Define to 1 if you are using `editline' or `vrl'.]) LIBS="$LIBS -ledit", AC_MSG_ERROR(editline library not found))) if test "${with_vrl+set}" = set -o "${with_readline+set}" = set; then @@ -189,9 +188,9 @@ dnl There are (at least) two incompatible versions of readline, and we dnl need to know which one we are using. We don't support readline 2.0. AC_ARG_WITH(readline, [ --with-readline Bloated GNU line editing], [ AC_CHECK_LIB(readline, readline, [ - AC_DEFINE(READLINE) + AC_DEFINE(READLINE, 1, [Define to 1 if you are using GNU `readline'.]) LIBS="$LIBS -lreadline $rc_lib_tgetent" - AC_CHECK_LIB(readline, _rl_clean_up_for_exit, , AC_DEFINE(READLINE_OLD), $rc_lib_tgetent) + AC_CHECK_LIB(readline, _rl_clean_up_for_exit, , AC_DEFINE(READLINE_OLD, 1, [Define to 1 for older versions GNU `readline'.]), $rc_lib_tgetent) ], AC_MSG_ERROR(readline library not found), $rc_lib_tgetent) ]) AM_CONDITIONAL(AMC_READLINE, test "${with_readline+set}" = set) diff --git a/glob.c b/glob.c @@ -1,7 +1,7 @@ /* glob.c: rc's (ugly) globber. This code is not elegant, but it works */ #include "rc.h" -#include <sys/stat.h> +#include "stat.h" /* Lifted from autoconf documentation.*/ #if HAVE_DIRENT_H @@ -86,7 +86,7 @@ extern List *glob(List *s) { /* Matches a pattern p against the contents of directory d */ static List *dmatch(char *d, char *p, char *m) { - bool matched = FALSE; + bool matched; List *top, *r; static DIR *dirp; static struct dirent *dp; @@ -107,7 +107,7 @@ static List *dmatch(char *d, char *p, char *m) { if (matched) { char *path = nprint("%s/%s", d, p); - if (stat(path, &s) < 0) + if (lstat(path, &s) < 0) return NULL; r = nnew(List); r->w = ncpy(p); diff --git a/history.c b/history.c @@ -78,6 +78,8 @@ static char *sub(char *s, char *old, char *new) { char *t, *u; t = isin(s, old); + if (!t) + return s; u = newstr(); *t = '\0'; @@ -206,9 +208,9 @@ static char *readhistoryfile(char **last) { exit(1); } - size = 0; - count = 0; - buf = ealloc(size = CHUNKSIZE); + size = CHUNKSIZE; + buf = ealloc(size); + buf[0] = '\0'; count = 1; /* sentinel */ while ((nread = fread(buf + count, sizeof (char), size - count, histfile)) > 0) { count += nread; if (size - count == 0) @@ -222,32 +224,30 @@ static char *readhistoryfile(char **last) { return buf; } -static char *getcommand() { +static char *getcommand(void) { char *s, *t; static char *hist = NULL, *last; if (hist == NULL) { hist = readhistoryfile(&last); - *--last = '\0'; /* trim final newline */ + *--last = '\0'; /* replaces final newline */ + ++hist; /* start beyond sentinel */ } again: s = last; if (s < hist) return NULL; - while (*--s != '\n') - if (s <= hist) { - last = hist - 1; - return hist; - } + while (s >= hist && *s != '\n') + --s; *s = '\0'; last = s++; /* * if the command contains the "me" character at the start of the line - * or after any of [`{|()@] then try again + * or after any of [`{|()@/] then try again */ - for (t = s; *t != '\0'; t++) + for (t = s; *t != '\0'; ++t) if (*t == me) { char *u = t - 1; while (u >= s && (*u == ' ' || *u == '\t')) diff --git a/input.c b/input.c @@ -96,8 +96,10 @@ static int fdgchar() { while (1) { #if EDITLINE || READLINE if (interactive && istack->t == iFd && isatty(istack->fd)) { - /* The readline library doesn't handle read() returning EAGAIN. */ + /* The readline library doesn't handle + * read() returning EAGAIN or EIO. */ makeblocking(istack->fd); + makesamepgrp(istack->fd); rlinebuf = rc_readline(prompt); if (rlinebuf == NULL) { chars_in = 0; diff --git a/nalloc.c b/nalloc.c @@ -112,8 +112,10 @@ extern void restoreblock(Block *old) { /* generic memory allocation functions */ extern void *ealloc(size_t n) { - void *p = malloc(n); + void *p; + assert(n); + p = malloc(n); if (p == NULL) { uerror("malloc"); rc_exit(1); diff --git a/rc.1 b/rc.1 @@ -161,7 +161,7 @@ .if !"\\$4"" .Xf \\$2 \\$1 "\\$3\\f\\$1\\$4\\*(Xi" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" .if "\\$4"" \\$3\fR\s10 .. -.TH RC 1 "2002-06-18" +.TH RC 1 "2003-07-17" .SH NAME rc \- shell .SH SYNOPSIS @@ -1435,9 +1435,11 @@ On startup, the first element of this list variable is initialized to a string which identifies this version of .IR rc . The second element is initialized to a string which can be found by -.B ident -and -.BR "sccs what" . +.IR ident (1) +and the +.I what +command of +.IR sccs (1). .SH FUNCTIONS .I rc functions are identical to @@ -1595,9 +1597,10 @@ For example: .TP \& is a reasonable way to pass a default set of arguments to -.Cr ls (1). +.Cr ls (1), +whereas .Ds -.Cr "fn ls { ls -FC $* }" +.Cr "fn ls { ls -FC $* } # WRONG" .De .TP \& @@ -2120,12 +2123,12 @@ builtin, the .Cr bqstatus and -.Cr rc_version +.Cr version variables, the support for the GNU .IR readline (3) -library and -the support for the +library, +and the support for the .Cr prompt function. This diff --git a/rc.h b/rc.h @@ -1,4 +1,4 @@ -#define NDEBUG 1 +#undef NDEBUG #include "config.h" #include "proto.h" diff --git a/signal.c b/signal.c @@ -8,17 +8,18 @@ #include "sigmsgs.h" #include "jbwrap.h" -#if HAVE_SA_INTERRUPT +#if HAVE_SIGACTION static void (*sys_signal(int signum, void (*handler)(int)))(int) { struct sigaction new, old; new.sa_handler = handler; - new.sa_flags = SA_INTERRUPT; + new.sa_flags = 0; /* clear SA_RESTART */ + sigfillset(&new.sa_mask); sigaction(signum, &new, &old); return old.sa_handler; } #else -#define sys_signal signal +#define sys_signal(sig, func) (signal((sig), (func))) #endif void (*sighandlers[NUMOFSIGNALS])(int); @@ -40,7 +41,7 @@ extern void catcher(int s) { #if HAVE_RESTARTABLE_SYSCALLS if (slow) { siglongjmp(slowbuf.j, s); -} + } #endif } @@ -96,6 +97,12 @@ extern void initsignal() { #endif for (i = 1; i < NUMOFSIGNALS; i++) { +#ifdef SIGKILL + if (i == SIGKILL) continue; +#endif +#ifdef SIGSTOP + if (i == SIGSTOP) continue; +#endif h = sys_signal(i, SIG_IGN); if (h != SIG_IGN && h != SIG_ERR) sys_signal(i, h); diff --git a/stat.h b/stat.h @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#if HAVE_LSTAT +#else +#define lstat(name, buf) (stat((name), (buf))) +#endif diff --git a/trip.rc b/trip.rc @@ -587,14 +587,10 @@ fn x {echo x.y $(x.y)} ~ ``''{whatis -f x} 'fn x {echo x.y $''x.y''} ' || fail sneaky parens bug -# large file support - -# this is, by no means, an exhaustive test. since particular file -# systems do, or do not, support large files, we try it both in the -# build directory and /tmp. - -if (./tripping l > big.$pid >[2] /dev/null || - ./tripping l > /tmp/big.$pid >[2] /dev/null) { - echo large file support seems to work -} else echo large file support seems NOT to work - see INSTALL file -rm -f big.$pid /tmp/big.$pid +# before rc-1.7.1, certain glob patterns could fail on broken symlinks +mkdir $tmp.qux +ln -s /frobnatz $tmp.qux/foo +x=$tmp.qux/foo* +~ $x $tmp.qux/foo || { rm -rf $tmp.qux; fail broken symlink globbing } +x=$tmp.qux*/foo +~ $x $tmp.qux/foo || { rm -rf $tmp.qux; fail broken symlink globbing } diff --git a/tripping.c b/tripping.c @@ -19,21 +19,6 @@ static void ctrl_a(void) { puts("a\001ab\002b"); } -static void large(void) { - char c = 'c'; - -#define LARGE (((off_t)1<<33)+1) - - if (lseek(1, LARGE, SEEK_SET) != LARGE) { - perror("lseek"); - exit(1); - } - if (write(1, &c, 1) == -1) { - perror("write"); - exit(1); - } -} - static void makenonblock(void) { int flags; @@ -52,9 +37,6 @@ int main(int argc, char **argv) { case 'a': ctrl_a(); break; - case 'l': - large(); - break; case 'n': makenonblock(); break; diff --git a/var.c b/var.c @@ -48,6 +48,7 @@ extern bool varassign_string(char *extdef) { strcpy(new->extdef, extdef); if (i != -1) alias(name, varlookup(name), FALSE); + set_exportable(name, TRUE); return TRUE; } diff --git a/which.c b/which.c @@ -37,6 +37,8 @@ static int ingidset(gid_t g) { return 1; return 0; } +#else +#define ingidset(g) (FALSE) #endif /* @@ -56,11 +58,7 @@ static bool rc_access(char *path, bool verbose) { mask = X_ALL; else if (uid == st.st_uid) mask = X_USR; -#if HAVE_GETGROUPS else if (gid == st.st_gid || ingidset(st.st_gid)) -#else - else if (gid == st.st_gid) -#endif mask = X_GRP; else mask = X_OTH; @@ -93,10 +91,12 @@ extern char *which(char *name, bool verbose) { rc_exit(1); } #else - ngroups = NGROUPS; + ngroups = NGROUPS; #endif - gidset = ealloc(ngroups * sizeof(GETGROUPS_T)); - getgroups(ngroups, gidset); + if (ngroups) { + gidset = ealloc(ngroups * sizeof(GETGROUPS_T)); + getgroups(ngroups, gidset); + } #endif } if (isabsolute(name)) /* absolute pathname? */