Commit 7a2d063d authored by Lucas Nussbaum's avatar Lucas Nussbaum

Imported Upstream version 6.17.00

parent e6f49ca5
21. V6.17.00 - 20090710
20. Fix dataroot autoconf issue.
19. Fix directory stuff for unit tests.
18. Fix small bug in history in loops.
17. Provide newer config.{guess,sub}
16. Fix gcc 4 warnings.
15. Fix memory trashing bug introduced in 10.
14. V6.16.01 - 20090624
13. add missing sigemptyset in goodbye()
12. add rlimit swapsize from FreeBSD.
11. restore behavior where a[n-] never prints an error.
10. always save the whole command, not just the first 80 chars of it.
9. fix short2str/short2qstr length adjustment in wide chars
(Vitezslav Crhonek)
8. set histfile=/tmp/history.temp; set savehist=(100 merge);
alias precmd history -S. After that justpr is not restored and commands
don't execute. (Andriy Gapon)
7. Fix "as" $ modifier from corrupting memory.
set t=demfonsftraftionf; echo $t:as/f//
6. Make $% work with environment variable (Ron Johnston)
5. Dragonfly script support (Matthias Schmidt, m65)
4. Add autoexpand=onlyhistory (Don Estabrook, m66)
3. Add history in loops (Laurence Darby, m48)
2. Add missing colorls "rs" variable (Shlomi Fish, m70)
1. Fix pts detection issue (Ruslan Ermilov)
33. V6.16.00 - 20080930
32. longjmp clobbered variable fixes.
31. __GNX__ addition
......
# $tcsh: Makefile.in,v 3.38 2008/09/25 14:40:35 christos Exp $
# $tcsh: Makefile.in,v 3.40 2009/06/24 22:09:05 christos Exp $
# Makefile.in 4.3 6/11/83
#
# C Shell with process control; VM/UNIX VAX Makefile
......@@ -278,7 +278,7 @@ P=
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
mandir=@mandir@
mandir=@datarootdir@/man
MANSECT=1
DESTBIN=${DESTDIR}${bindir}
DESTMAN=${DESTDIR}${mandir}/man${MANSECT}
......@@ -463,7 +463,7 @@ $(srcdir)/tests/package.m4: $(srcdir)/configure.in
echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
} >$(srcdir)/tests/package.m4
$(srcdir)/tests/testsuite: tests/package.m4 tests/testsuite.at $(TESTFILES)
$(srcdir)/tests/testsuite: $(srcdir)/tests/package.m4 $(srcdir}/tests/testsuite.at $(TESTFILES)
autom4te --language=autotest -I $(srcdir)/tests \
$(srcdir)/tests/testsuite.at -o $@.tmp
mv $@.tmp $@
......
This is tcsh version 6.16.00. Tcsh is a version of the Berkeley
This is tcsh version 6.17.00. Tcsh is a version of the Berkeley
C-Shell, with the addition of: a command line editor, command and file
name completion, listing, etc. and a bunch of small additions to the
shell itself.
......
This diff is collapsed.
This diff is collapsed.
/* $Header: /p/tcsh/cvsroot/tcsh/config_f.h,v 3.40 2006/08/28 14:53:04 mitr Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/config_f.h,v 3.42 2009/06/25 12:10:56 christos Exp $ */
/*
* config_f.h -- configure various defines for tcsh
*
......@@ -143,7 +143,7 @@
* This can be much slower and no memory statistics will be
* provided.
*/
#if defined(__MACHTEN__) || defined(PURIFY) || defined(MALLOC_TRACE) || defined(_OSD_POSIX) || defined(__MVS__) || defined (__linux__)
#if defined(__MACHTEN__) || defined(PURIFY) || defined(MALLOC_TRACE) || defined(_OSD_POSIX) || defined(__MVS__)
# define SYSMALLOC
#else
# undef SYSMALLOC
......@@ -189,7 +189,7 @@
# ifndef __GNUC__
# define RCSID(id) static char *rcsid = (id);
# else
# define RCSID(id) static char *rcsid(const char *a) { return rcsid(a = id); }
# define RCSID(id) static const char rcsid[] __attribute__((__used__)) = (id);
# endif /* !__GNUC__ */
#else
# define RCSID(id) /* Nothing */
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for tcsh 6.16.00.
# Generated by GNU Autoconf 2.61 for tcsh 6.17.00.
#
# Report bugs to <http://bugs.gw.com/>.
#
......@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='tcsh'
PACKAGE_TARNAME='tcsh'
PACKAGE_VERSION='6.16.00'
PACKAGE_STRING='tcsh 6.16.00'
PACKAGE_VERSION='6.17.00'
PACKAGE_STRING='tcsh 6.17.00'
PACKAGE_BUGREPORT='http://bugs.gw.com/'
ac_unique_file="tc.vers.c"
......@@ -1189,7 +1189,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures tcsh 6.16.00 to adapt to many kinds of systems.
\`configure' configures tcsh 6.17.00 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1254,7 +1254,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of tcsh 6.16.00:";;
short | recursive ) echo "Configuration of tcsh 6.17.00:";;
esac
cat <<\_ACEOF
......@@ -1346,7 +1346,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
tcsh configure 6.16.00
tcsh configure 6.17.00
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1360,7 +1360,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by tcsh $as_me 6.16.00, which was
It was created by tcsh $as_me 6.17.00, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -1929,6 +1929,11 @@ case "${host}" in
tcsh_config_file=bsd4.4
;;
## DragonFlyBSD systems
*-*-dragonfly*)
tcsh_config_file=bsd4.4
;;
## OpenBSD systems
*-*-openbsd*)
tcsh_config_file=bsd4.4
......@@ -8939,7 +8944,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by tcsh $as_me 6.16.00, which was
This file was extended by tcsh $as_me 6.17.00, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -8992,7 +8997,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
tcsh config.status 6.16.00
tcsh config.status 6.17.00
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
......@@ -9,7 +9,7 @@ dnl Written by Kaveh Ghazi (ghazi@caip.rutgers.edu) 5/11/96.
dnl
AC_PREREQ([2.59])dnl Minimum Autoconf version required.
AC_INIT([tcsh], [6.16.00], [http://bugs.gw.com/])
AC_INIT([tcsh], [6.17.00], [http://bugs.gw.com/])
AC_CONFIG_SRCDIR([tc.vers.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_TESTDIR([.], [.])
......@@ -106,6 +106,11 @@ case "${host}" in
tcsh_config_file=bsd4.4
;;
## DragonFlyBSD systems
*-*-dragonfly*)
tcsh_config_file=bsd4.4
;;
## OpenBSD systems
*-*-openbsd*)
tcsh_config_file=bsd4.4
......
/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.93 2006/08/23 15:03:13 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.95 2009/06/25 21:15:37 christos Exp $ */
/*
* ed.chared.c: Character editing functions.
*/
......@@ -72,7 +72,7 @@
#include "sh.h"
RCSID("$tcsh: ed.chared.c,v 3.93 2006/08/23 15:03:13 christos Exp $")
RCSID("$tcsh: ed.chared.c,v 3.95 2009/06/25 21:15:37 christos Exp $")
#include "ed.h"
#include "tw.h"
......@@ -120,8 +120,8 @@ static Char *c_prev_word (Char *, Char *, int);
static Char *c_next_word (Char *, Char *, int);
static Char *c_number (Char *, int *, int);
static Char *c_expand (Char *);
static void c_excl (Char *);
static void c_substitute (void);
static int c_excl (Char *);
static int c_substitute (void);
static void c_delfini (void);
static int c_hmatch (Char *);
static void c_hsetpat (void);
......@@ -682,13 +682,16 @@ excl_err:
* space (or the beginning of the buffer) and properly expand all the excl's
* from there up to the current cursor position. We also avoid (trying to)
* expanding '>!'
* Returns number of expansions attempted (doesn't matter whether they succeeded
* or not).
*/
static void
static int
c_excl(Char *p)
{
int i;
Char *q;
int nr_exp;
/*
* if />[SPC TAB]*![SPC TAB]/, back up p to just after the >. otherwise,
......@@ -708,9 +711,10 @@ c_excl(Char *p)
/*
* Forever: Look for history char. (Stop looking when we find the cursor.)
* Count backslashes. Of odd, skip history char. Return if all done.
* Expand if even number of backslashes.
* Count backslashes. If odd, skip history char. Expand if even number of
* backslashes.
*/
nr_exp = 0;
for (;;) {
while (*p != HIST && p < Cursor)
++p;
......@@ -718,18 +722,23 @@ c_excl(Char *p)
continue;
if (i % 2 == 0)
++p;
if (p >= Cursor)
return;
if (i % 2 == 1)
if (p >= Cursor) /* all done */
return nr_exp;
if (i % 2 == 1) {
p = c_expand(p);
++nr_exp;
}
}
return nr_exp;
}
static void
static int
c_substitute(void)
{
Char *p;
int nr_exp;
/*
* Start p out one character before the cursor. Move it backwards looking
......@@ -743,8 +752,12 @@ c_substitute(void)
* If we found a history character, go expand it.
*/
if (*p == HIST)
c_excl(p);
nr_exp = c_excl(p);
else
nr_exp = 0;
Refresh();
return nr_exp;
}
static void
......@@ -3441,13 +3454,20 @@ e_tty_stopo(Char c)
return(CC_NORM);
}
/* returns the number of (attempted) expansions */
int
ExpandHistory(void)
{
*LastChar = '\0'; /* just in case */
return c_substitute();
}
/*ARGSUSED*/
CCRETVAL
e_expand_history(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
c_substitute();
(void)ExpandHistory();
return(CC_NORM);
}
......@@ -3457,7 +3477,7 @@ e_magic_space(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
c_substitute();
(void)c_substitute();
return(e_insert(' '));
}
......@@ -3548,7 +3568,7 @@ e_load_average(Char c)
*/
if (ioctl(SHIN, TIOCSTAT, (ioctl_t) &c) < 0)
#endif
xprintf(CGETS(5, 1, "Load average unavailable\n"));
xprintf("%s", CGETS(5, 1, "Load average unavailable\n"));
return(CC_REFRESH);
}
......
/* $Header: /p/tcsh/cvsroot/tcsh/ed.decls.h,v 3.44 2006/08/23 15:03:13 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/ed.decls.h,v 3.45 2008/10/17 20:25:00 christos Exp $ */
/*
* ed.decls.h: Editor external definitions
*/
......@@ -37,6 +37,7 @@
* ed.chared.c
*/
extern int InsertStr (Char *);
extern int ExpandHistory (void);
extern void DeleteBack (int);
extern void SetKillRing (int);
extern CCRETVAL GetHistLine (void);
......@@ -194,6 +195,7 @@ extern CCRETVAL e_copyregion (Char);
extern CCRETVAL e_tty_int (Char);
extern CCRETVAL e_run_fg_editor (Char);
extern CCRETVAL e_list_eof (Char);
extern int e_expand_history_rne (Char);
extern CCRETVAL e_expand_history (Char);
extern CCRETVAL e_magic_space (Char);
extern CCRETVAL e_list_glob (Char);
......
/* $Header: /p/tcsh/cvsroot/tcsh/ed.inputl.c,v 3.67 2007/09/28 21:02:02 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/ed.inputl.c,v 3.70 2009/06/25 21:15:37 christos Exp $ */
/*
* ed.inputl.c: Input line handling.
*/
......@@ -32,7 +32,7 @@
*/
#include "sh.h"
RCSID("$tcsh: ed.inputl.c,v 3.67 2007/09/28 21:02:02 christos Exp $")
RCSID("$tcsh: ed.inputl.c,v 3.70 2009/06/25 21:15:37 christos Exp $")
#include "ed.h"
#include "ed.defns.h" /* for the function names */
......@@ -91,10 +91,12 @@ Inputl(void)
struct varent *imode = adrof(STRinputmode);
Char *SaveChar, *CorrChar;
int matchval; /* from tenematch() */
int nr_history_exp; /* number of (attempted) history expansions */
COMMAND fn;
int curlen = 0;
int newlen;
int idx;
Char *autoexpand;
if (!MapsAreInited) /* double extra just in case */
ed_InitMaps();
......@@ -262,13 +264,13 @@ Inputl(void)
ch = tch;
if (ch == 'y' || ch == ' ') {
LastChar = CorrChar; /* Restore the corrected end */
xprintf(CGETS(6, 2, "yes\n"));
xprintf("%s", CGETS(6, 2, "yes\n"));
}
else {
Strcpy(InputBuf, Origin);
LastChar = SaveChar;
if (ch == 'e') {
xprintf(CGETS(6, 3, "edit\n"));
xprintf("%s", CGETS(6, 3, "edit\n"));
*LastChar-- = '\0';
Cursor = LastChar;
printprompt(3, NULL);
......@@ -279,7 +281,7 @@ Inputl(void)
break;
}
else if (ch == 'a') {
xprintf(CGETS(6, 4, "abort\n"));
xprintf("%s", CGETS(6, 4, "abort\n"));
LastChar = InputBuf; /* Null the current line */
Cursor = LastChar;
printprompt(0, NULL);
......@@ -287,7 +289,7 @@ Inputl(void)
cleanup_until(Origin);
break;
}
xprintf(CGETS(6, 5, "no\n"));
xprintf("%s", CGETS(6, 5, "no\n"));
}
flush();
}
......@@ -307,9 +309,9 @@ Inputl(void)
PastBottom();
}
if (matchval == 0) {
xprintf(CGETS(6, 6, "No matching command\n"));
xprintf("%s", CGETS(6, 6, "No matching command\n"));
} else if (matchval == 2) {
xprintf(CGETS(6, 7, "Ambiguous command\n"));
xprintf("%s", CGETS(6, 7, "Ambiguous command\n"));
}
if (NeedsRedraw) {
ClearLines();
......@@ -396,8 +398,14 @@ Inputl(void)
curlen = (int) (LastChar - InputBuf);
if (adrof(STRautoexpand))
(void) e_expand_history(0);
nr_history_exp = 0;
autoexpand = varval(STRautoexpand);
if (autoexpand != STRNULL)
nr_history_exp += ExpandHistory();
/* try normal expansion only if no history references were found */
if (nr_history_exp == 0 ||
Strcmp(autoexpand, STRonlyhistory) != 0) {
/*
* Modified by Martin Boyer (gamin@ireq-robot.hydro.qc.ca):
* A separate variable now controls beeping after
......@@ -406,7 +414,8 @@ Inputl(void)
expnum = (int) (Cursor - InputBuf);
switch (matchval = tenematch(InputBuf, Cursor-InputBuf, fn)){
case 1:
if (non_unique_match && matchbeep && matchbeep->vec != NULL &&
if (non_unique_match && matchbeep &&
matchbeep->vec != NULL &&
(Strcmp(*(matchbeep->vec), STRnotunique) == 0))
SoundBeep();
break;
......@@ -456,6 +465,7 @@ Inputl(void)
}
break;
}
}
if (NeedsRedraw) {
PastBottom();
ClearLines();
......
/* $Header: /p/tcsh/cvsroot/tcsh/ed.screen.c,v 3.75 2006/08/24 20:56:31 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/ed.screen.c,v 3.76 2009/06/25 21:15:37 christos Exp $ */
/*
* ed.screen.c: Editor/termcap-curses interface
*/
......@@ -32,7 +32,7 @@
*/
#include "sh.h"
RCSID("$tcsh: ed.screen.c,v 3.75 2006/08/24 20:56:31 christos Exp $")
RCSID("$tcsh: ed.screen.c,v 3.76 2009/06/25 21:15:37 christos Exp $")
#include "ed.h"
#include "tc.h"
......@@ -383,8 +383,8 @@ TellTC(void)
struct termcapstr *t;
char *first, *s;
xprintf(CGETS(7, 1, "\n\tTcsh thinks your terminal has the\n"));
xprintf(CGETS(7, 2, "\tfollowing characteristics:\n\n"));
xprintf("%s", CGETS(7, 1, "\n\tTcsh thinks your terminal has the\n"));
xprintf("%s", CGETS(7, 2, "\tfollowing characteristics:\n\n"));
xprintf(CGETS(7, 3, "\tIt has %d columns and %d lines\n"),
Val(T_co), Val(T_li));
s = strsave(T_HasMeta ? CGETS(7, 5, "a") : CGETS(7, 6, "no"));
......@@ -610,7 +610,7 @@ EchoTC(Char **v)
scap = tgetstr(cv, &area);
if (!scap || scap[0] == '\0') {
if (tgetflag(cv)) {
xprintf(CGETS(7, 14, "yes\n"));
xprintf("%s", CGETS(7, 14, "yes\n"));
goto end;
}
if (silent)
......
/* $Header: /p/tcsh/cvsroot/tcsh/ed.xmap.c,v 3.36 2006/11/29 22:30:09 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/ed.xmap.c,v 3.37 2009/06/25 21:15:37 christos Exp $ */
/*
* ed.xmap.c: This module contains the procedures for maintaining
* the extended-key map.
......@@ -88,7 +88,7 @@
*/
#include "sh.h"
RCSID("$tcsh: ed.xmap.c,v 3.36 2006/11/29 22:30:09 christos Exp $")
RCSID("$tcsh: ed.xmap.c,v 3.37 2009/06/25 21:15:37 christos Exp $")
#include "ed.h"
#include "ed.defns.h"
......@@ -216,12 +216,13 @@ AddXkey(const CStr *Xkey, XmapVal *val, int ntype)
cs.buf = Xkey->buf;
cs.len = Xkey->len;
if (Xkey->len == 0) {
xprintf(CGETS(9, 1, "AddXkey: Null extended-key not allowed.\n"));
xprintf("%s", CGETS(9, 1, "AddXkey: Null extended-key not allowed.\n"));
return;
}
if (ntype == XK_CMD && val->cmd == F_XKEY) {
xprintf(CGETS(9, 2, "AddXkey: sequence-lead-in command not allowed\n"));
xprintf("%s",
CGETS(9, 2, "AddXkey: sequence-lead-in command not allowed\n"));
return;
}
......@@ -318,7 +319,8 @@ DeleteXkey(const CStr *Xkey)
s = *Xkey;
if (s.len == 0) {
xprintf(CGETS(9, 3, "DeleteXkey: Null extended-key not allowed.\n"));
xprintf("%s",
CGETS(9, 3, "DeleteXkey: Null extended-key not allowed.\n"));
return (-1);
}
......@@ -669,7 +671,7 @@ parseescape(const Char **ptr)
val = (val << 3) | (ch - '0');
}
if ((val & ~0xff) != 0) {
xprintf(CGETS(9, 9,
xprintf("%s", CGETS(9, 9,
"Octal constant does not fit in a char.\n"));
return 0;
}
......
......@@ -329,8 +329,8 @@ glob(const char *pattern, int flags, int (*errfunc) (const char *, int),
len = mblen((const char *)(patnext - 1), MB_LEN_MAX);
if (len == -1)
mblen(NULL, 0);
if (len > 1) {
(void)mblen(NULL, 0);
else if (len > 1) {
*bufnext++ = (Char) c;
while (--len != 0)
*bufnext++ = (Char) (*patnext++ | M_PROTECT);
......
/* $Header: /p/tcsh/cvsroot/tcsh/patchlevel.h,v 3.164 2008/09/30 18:57:19 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/patchlevel.h,v 3.167 2009/07/10 17:09:32 christos Exp $ */
/*
* patchlevel.h: Our life story.
*/
......@@ -7,8 +7,8 @@
#define ORIGIN "Astron"
#define REV 6
#define VERS 16
#define VERS 17
#define PATCHLEVEL 0
#define DATE "2008-09-30"
#define DATE "2009-07-10"
#endif /* _h_patchlevel */
/* $Header: /p/tcsh/cvsroot/tcsh/sh.c,v 3.140 2008/09/25 14:41:48 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/sh.c,v 3.145 2009/06/25 21:15:37 christos Exp $ */
/*
* sh.c: Main shell routines
*/
......@@ -39,7 +39,7 @@ char copyright[] =
All rights reserved.\n";
#endif /* not lint */
RCSID("$tcsh: sh.c,v 3.140 2008/09/25 14:41:48 christos Exp $")
RCSID("$tcsh: sh.c,v 3.145 2009/06/25 21:15:37 christos Exp $")
#include "tc.h"
#include "ed.h"
......@@ -139,6 +139,7 @@ struct saved_state {
Char HIST;
int cantell;
struct Bin B;
int justpr;
};
static int srccat (Char *, Char *);
......@@ -458,7 +459,7 @@ main(int argc, char **argv)
else
cp2 = cp;
if (!(((Strncmp(cp2, STRtty, 3) == 0) && Isalpha(cp2[3])) ||
Strstr(cp, STRslptssl) != NULL)) {
Strstr(cp, STRptssl) != NULL)) {
if (getenv("DISPLAY") == NULL) {
/* NOT on X window shells */
setcopy(STRautologout, STRdefautologout, VAR_READWRITE);
......@@ -757,7 +758,7 @@ main(int argc, char **argv)
}
if (argc > 1 && strcmp(argv[1], "--help") == 0) {
xprintf("%S\n\n", varval(STRversion));
xprintf(CGETS(11, 8, HELP_STRING));
xprintf("%s", CGETS(11, 8, HELP_STRING));
xexit(0);
}
/*
......@@ -1103,17 +1104,7 @@ main(int argc, char **argv)
}
#endif /* NeXT */
#ifdef BSDJOBS /* if we have tty job control */
retry:
if ((tpgrp = tcgetpgrp(f)) != -1) {
if (tpgrp != shpgrp) {
struct sigaction old;
sigaction(SIGTTIN, NULL, &old);
signal(SIGTTIN, SIG_DFL);
(void) kill(0, SIGTTIN);
sigaction(SIGTTIN, &old, NULL);
goto retry;
}
if (grabpgrp(f, shpgrp) != -1) {
/*
* Thanks to Matt Day for the POSIX references, and to
* Paul Close for the SGI clarification.
......@@ -1172,7 +1163,8 @@ main(int argc, char **argv)
notty:
xprintf(CGETS(11, 1, "Warning: no access to tty (%s).\n"),
strerror(errno));
xprintf(CGETS(11, 2, "Thus no job control in this shell.\n"));
xprintf("%s",
CGETS(11, 2, "Thus no job control in this shell.\n"));
/*
* Fix from:Sakari Jalovaara <sja@sirius.hut.fi> if we don't
* have access to tty, disable editing too
......@@ -1480,6 +1472,7 @@ st_save(struct saved_state *st, int unit, int hflg, Char **al, Char **av)
st->alvec = alvec;
st->onelflg = onelflg;
st->enterhist = enterhist;
st->justpr = justpr;
if (hflg)
st->HIST = HIST;
else
......@@ -1578,6 +1571,7 @@ st_restore(void *xst)
HIST = st->HIST;
enterhist = st->enterhist;
cantell = st->cantell;
justpr = st->justpr;
if (st->argv != NULL)
setq(STRargv, st->argv, &shvhed, VAR_READWRITE);
......@@ -1647,6 +1641,7 @@ goodbye(Char **v, struct command *c)
size_t omark;
sigset_t set;
sigemptyset(&set);
signal(SIGQUIT, SIG_IGN);
sigaddset(&set, SIGQUIT);
sigprocmask(SIG_UNBLOCK, &set, NULL);
......@@ -2356,3 +2351,28 @@ record(void)
rechist(NULL, adrof(STRsavehist) != NULL);
}
}
/*
* Grab the tty repeatedly, and give up if we are not in the correct
* tty process group.
*/
int
grabpgrp(int fd, pid_t desired)
{
struct sigaction old;
pid_t pgrp;
size_t i;
for (i = 0; i < 100; i++) {
if ((pgrp = tcgetpgrp(fd)) == -1)
return -1;
if (pgrp == desired)
return 0;
(void)sigaction(SIGTTIN, NULL, &old);
(void)signal(SIGTTIN, SIG_DFL);
(void)kill(0, SIGTTIN);
(void)sigaction(SIGTTIN, &old, NULL);
}
errno = EPERM;
return -1;
}
/* $Header: /p/tcsh/cvsroot/tcsh/sh.decls.h,v 3.54 2007/03/11 06:21:05 amold Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/sh.decls.h,v 3.55 2009/02/25 22:54:54 christos Exp $ */
/*
* sh.decls.h External declarations from sh*.c
*/
......@@ -52,6 +52,7 @@ extern void done (int);
#else
extern void xexit (int);
#endif
extern int grabpgrp (int, pid_t);
/*
* sh.dir.c
......
/* $Header: /p/tcsh/cvsroot/tcsh/sh.dol.c,v 3.74 2008/05/14 20:10:30 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/sh.dol.c,v 3.77 2009/06/19 16:25:00 christos Exp $ */
/*
* sh.dol.c: Variable substitutions
*/
......@@ -32,7 +32,7 @@
*/
#include "sh.h"
RCSID("$tcsh: sh.dol.c,v 3.74 2008/05/14 20:10:30 christos Exp $")
RCSID("$tcsh: sh.dol.c,v 3.77 2009/06/19 16:25:00 christos Exp $")
/*
* C shell
......@@ -587,9 +587,13 @@ Dgetdol(void)
cleanup_until(name);
fixDolMod();
if (length) {
addla(putn(Strlen(np)));
} else {
xfree(env_val);
env_val = Strsave(np);
setDolp(env_val);
}
goto eatbrac;
}
udvar(name->s);
......@@ -621,7 +625,7 @@ Dgetdol(void)
for (i = 0; Isdigit(*np); i = i * 10 + *np++ - '0')
continue;
if (i < 0 || i > upb) {
if (i < 0 || i > upb && !any("-*", *np)) {
cleanup_until(name);
dolerror(vp->v_name);
return;
......@@ -815,8 +819,8 @@ setDolp(Char *cp)
dp = Strstr(dp, lhsub);
if (dp) {
ptrdiff_t diff = dp - cp;
np = xmalloc((Strlen(cp) + 1 - lhlen + rhlen) *
sizeof(Char));
size_t len = (Strlen(cp) + 1 - lhlen + rhlen);
np = xmalloc(len * sizeof(Char));
(void) Strncpy(np, cp, diff);
(void) Strcpy(np + diff, rhsub);
(void) Strcpy(np + diff + rhlen, dp + lhlen);
......@@ -824,7 +828,10 @@ setDolp(Char *cp)
dp = np + diff + 1;
xfree(cp);
cp = np;
cp[--len] = '\0';
didmod = 1;
if (diff >= len)
break;
} else {
/* should this do a seterror? */
break;
......
/* $Header: /p/tcsh/cvsroot/tcsh/sh.exec.c,v 3.74 2007/05/31 08:26:12 corinna Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/sh.exec.c,v 3.75 2009/06/25 21:15:37 christos Exp $ */
/*
* sh.exec.c: Search, find, and execute a command!
*/
......@@ -32,7 +32,7 @@
*/
#include "sh.h"
RCSID("$tcsh: sh.exec.c,v 3.74 2007/05/31 08:26:12 corinna Exp $")
RCSID("$tcsh: sh.exec.c,v 3.75 2009/06/25 21:15:37 christos Exp $")
#include "tc.h"
#include "tw.h"
......@@ -1066,7 +1066,7 @@ find_cmd(Char *cmd, int prt)