rc

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

commit 826eea2e08a9ec4254ccbd4d12fcd7828f8c413d
parent c8a77b86b4f8c91314222a8e12e6e37cf182ee10
Author: Toby Goodwin <LibreSoftwareDesign@gmail.com>
Date:   Mon,  1 Oct 2012 21:51:47 +0100

various minor fixups

Diffstat:
Macinclude.m4 | 18+++++++++---------
Mtrip.rc | 10+++++-----
Mwhich.c | 31+++++++++++++++++--------------
3 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4 @@ -16,7 +16,7 @@ int main(void) { dnl We can't use AC_CHECK_FUNCS for sigsetjmp(), since it's a macro in dnl some places. -AC_DEFUN(RC_FUNC_SIGSETJMP, [ +AC_DEFUN([RC_FUNC_SIGSETJMP], [ AC_CACHE_CHECK(for sigsetjmp, rc_cv_sigsetjmp, AC_TRY_LINK([ #include <setjmp.h> @@ -30,7 +30,7 @@ sigsetjmp(e, 1); ]) dnl Similarly, AC_CHECK_FUNCS doesn't find strerror() on NetBSD. -AC_DEFUN(RC_FUNC_STRERROR, [ +AC_DEFUN([RC_FUNC_STRERROR], [ AC_CACHE_CHECK(for strerror, rc_cv_strerror, AC_TRY_LINK([ #include <string.h> @@ -43,7 +43,7 @@ strerror(0); ]) dnl HPUX needs _KERNEL defined to pick up RLIMIT_foo defines. (Why?) -AC_DEFUN(RC_NEED_KERNEL, [ +AC_DEFUN([RC_NEED_KERNEL], [ AC_CACHE_CHECK(if _KERNEL is required for RLIMIT defines, rc_cv_kernel_rlimit, AC_TRY_COMPILE([ #include <sys/types.h> @@ -66,7 +66,7 @@ f = RLIMIT_DATA; ]) dnl Look for rlim_t in sys/types.h and sys/resource.h -AC_DEFUN(RC_TYPE_RLIM_T, [ +AC_DEFUN([RC_TYPE_RLIM_T], [ AC_CACHE_CHECK(for rlim_t, rc_cv_have_rlim_t, AC_EGREP_CPP(rlim_t, [ #include <sys/types.h> @@ -118,7 +118,7 @@ main(){ dnl Check type of sig_atomic_t. -AC_DEFUN(RC_TYPE_SIG_ATOMIC_T, [ +AC_DEFUN([RC_TYPE_SIG_ATOMIC_T], [ AC_CACHE_CHECK(for sig_atomic_t, rc_cv_sig_atomic_t, AC_EGREP_HEADER(sig_atomic_t, signal.h, rc_cv_sig_atomic_t=yes, rc_cv_sig_atomic_t=no)) @@ -135,7 +135,7 @@ dnl semantics, but if the parent calls wait() before the child calls dnl exit(), wait() returns with the PID of the child as normal. (Real dnl SysV waits for all children to exit, then returns with ECHILD.) dnl Anyway, this is why the `sleep(1)' is there. -AC_DEFUN(RC_SYS_V_SIGCLD, [ +AC_DEFUN([RC_SYS_V_SIGCLD], [ AC_CACHE_CHECK(for SysV SIGCLD semantics, rc_cv_sysv_sigcld, AC_TRY_RUN([ #include <errno.h> @@ -165,7 +165,7 @@ int main(void) { dnl Do we have /dev/fd or /proc/self/fd? -AC_DEFUN(RC_SYS_DEV_FD, [ +AC_DEFUN([RC_SYS_DEV_FD], [ AC_CACHE_CHECK(for /dev/fd, rc_cv_sys_dev_fd, if test -d /dev/fd && test -r /dev/fd/0; then rc_cv_sys_dev_fd=yes @@ -179,7 +179,7 @@ AC_DEFUN(RC_SYS_DEV_FD, [ dnl Can mknod make FIFOs? -AC_DEFUN(RC_SYS_MKNOD_FIFO, [ +AC_DEFUN([RC_SYS_MKNOD_FIFO], [ AC_CACHE_CHECK(for mknod FIFOs, rc_cv_sys_fifo, AC_TRY_RUN([ #include <sys/types.h> @@ -196,7 +196,7 @@ main() { ]) dnl Where is tgetent()? -AC_DEFUN(RC_LIB_TGETENT, [ +AC_DEFUN([RC_LIB_TGETENT], [ AC_CHECK_LIB(termcap, tgetent, rc_lib_tgetent=-ltermcap, AC_CHECK_LIB(ncurses, tgetent, diff --git a/trip.rc b/trip.rc @@ -51,12 +51,12 @@ if (false) { # WARNING: this differs from sh umask 0 > $tmp x=`{ls -l $tmp} -if (!~ $x(1) '-rw-rw-rw-') fail umask 0 produced incorrect result: $x(1) +if (!~ $x(1) -rw-rw-rw-*) fail umask 0 produced incorrect result: $x(1) rm -f $tmp umask 027 > $tmp y=`{ls -l $tmp} -if (!~ $y(1) '-rw-r-----') fail umask 027 produced incorrect file: $y(1) +if (!~ $y(1) -rw-r-----*) fail umask 027 produced incorrect file: $y(1) rm -f $tmp if (!~ `umask 027) fail umask reported bad value: `umask @@ -382,7 +382,7 @@ chmod a-x /tmp/noexec.$pid $rc -c /tmp/noexec.$pid >[2]/dev/null && fail /tmp/noexec.$pid is found!? rm /tmp/noexec.$pid -submatch 'path='''' frobnatz' 'frobnatz not found' 'search error' +submatch 'path='''' frobnatz' 'rc: cannot find `frobnatz''' 'search error' {path=() /bin/sh -c 'exit 0'} || fail abs pathname with path set to null @@ -564,7 +564,7 @@ x=/* # fn sigexit should be cleared in children x = () -expect nonesuch not found +expect rc: cannot find '`nonesuch''' x = `{true | nonesuch}; if (~ $x trip) fail sigexit in children x = `{ < /dev/null wc |grep xxx }; if (~ $x trip) fail sigexit in children x = `{{ wc | wc } < /dev/null }; if (~ $x trip) fail sigexit in children @@ -575,7 +575,7 @@ x = `{{ wc | wc } < /dev/null }; if (~ $x trip) fail sigexit in children # check for ctrl-a bug x=`{./tripping a} -# ~ `{$rc -c 'echo $x'} $x || fail ctrl-a bug detected +~ `{$rc -c 'echo $x'} $x || fail ctrl-a bug detected # check for hilarious quoting bug introduced while fixing ctrl-a x=('#' '#' '#') diff --git a/which.c b/which.c @@ -70,22 +70,25 @@ static bool rc_access(char *path, bool verbose) { return FALSE; } +/* 2012-10-01 I don't know where this routine came from. Obviously I can + * see what it's doing, and were it implemented properly it might be a + * good thing. */ static char *protect(char *in) { - char *out = ealloc(strlen(in) * 2 + 1); - - int i; - int p = 0; + char *out = ealloc(strlen(in) * 2 + 1); - for (i = 0; i < strlen(in); ++i) { - if (isprint(in[i])) { - out[p++] = in[i]; - ++p; - } else { - out[p++] = '\\'; - out[p++] = '?'; - } - } - return out; /* XXXX */ + int i; + int p = 0; + + for (i = 0; i < strlen(in); ++i) { + if (isprint(in[i])) { + out[p++] = in[i]; + } else { + out[p++] = '\\'; + out[p++] = '?'; + } + } + out[p] = '\0'; + return out; /* XXXX */ } /* return a full pathname by searching $path, and by checking the status of the file */