summaryrefslogtreecommitdiff
path: root/sh.set.c
diff options
context:
space:
mode:
Diffstat (limited to 'sh.set.c')
-rw-r--r--sh.set.c61
1 files changed, 59 insertions, 2 deletions
diff --git a/sh.set.c b/sh.set.c
index 0f98a2b0d314e..cf831b2577405 100644
--- a/sh.set.c
+++ b/sh.set.c
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.set.c,v 3.83 2012/01/15 17:15:28 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.set.c,v 3.89 2015/09/08 15:49:53 christos Exp $ */
/*
* sh.set.c: Setting and Clearing of variables
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$tcsh: sh.set.c,v 3.83 2012/01/15 17:15:28 christos Exp $")
+RCSID("$tcsh: sh.set.c,v 3.89 2015/09/08 15:49:53 christos Exp $")
#include "ed.h"
#include "tw.h"
@@ -55,6 +55,7 @@ static struct varent *madrof (Char *, struct varent *);
static void unsetv1 (struct varent *);
static void exportpath (Char **);
static void balance (struct varent *, int, int);
+static int set_noclobber (Char **);
/*
* C Shell
@@ -72,6 +73,13 @@ update_vars(Char *vp)
dohash(NULL, NULL);
}
}
+ else if (eq(vp, STRnoclobber)) {
+ struct varent *p = adrof(STRnoclobber);
+ if (p == NULL)
+ stderror(ERR_NAME | ERR_UNDVAR);
+ else
+ no_clobber = set_noclobber(p->vec);
+ }
else if (eq(vp, STRhistchars)) {
Char *pn = varval(vp);
@@ -165,6 +173,10 @@ update_vars(Char *vp)
noediting = 0;
/* PWP: add more stuff in here later */
}
+ else if (eq(vp, STRvimode)) {
+ VImode = 1;
+ update_wordchars();
+ }
else if (eq(vp, STRshlvl)) {
tsetenv(STRKSHLVL, varval(vp));
}
@@ -195,6 +207,9 @@ update_vars(Char *vp)
else if (eq(vp, STRkillring)) {
SetKillRing((int)getn(varval(vp)));
}
+ else if (eq(vp, STRhistory)) {
+ sethistory((int)getn(varval(vp)));
+ }
#ifndef HAVENOUTMP
else if (eq(vp, STRwatch)) {
resetwatch();
@@ -203,6 +218,9 @@ update_vars(Char *vp)
else if (eq(vp, STRimplicitcd)) {
implicit_cd = ((eq(varval(vp), STRverbose)) ? 2 : 1);
}
+ else if (eq(vp, STRcdtohome)) {
+ cdtohome = 1;
+ }
#ifdef COLOR_LS_F
else if (eq(vp, STRcolor)) {
set_color_context();
@@ -762,6 +780,8 @@ unset(Char **v, struct command *c)
PRCH = tcsh ? '>' : '%';
PRCHROOT = '#';
}
+ if (adrof(STRnoclobber) == 0)
+ no_clobber = 0;
if (adrof(STRhistlit) == 0)
HistLit = 0;
if (adrof(STRloginsh) == 0)
@@ -780,12 +800,18 @@ unset(Char **v, struct command *c)
symlinks = 0;
if (adrof(STRimplicitcd) == 0)
implicit_cd = 0;
+ if (adrof(STRcdtohome) == 0)
+ cdtohome = 0;
if (adrof(STRkillring) == 0)
SetKillRing(0);
if (did_edit && noediting && adrof(STRedit) == 0)
noediting = 0;
+ if (adrof(STRvimode) == 0)
+ VImode = 0;
if (did_roe && adrof(STRrecognize_only_executables) == 0)
tw_cmd_free();
+ if (adrof(STRhistory) == 0)
+ sethistory(0);
#ifdef COLOR_LS_F
if (adrof(STRcolor) == 0)
set_color_context();
@@ -793,6 +819,7 @@ unset(Char **v, struct command *c)
#if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
update_dspmbyte_vars();
#endif
+ update_wordchars();
#ifdef NLS_CATALOGS
nlsclose();
nlsinit();
@@ -920,6 +947,28 @@ exportpath(Char **val)
cleanup_until(exppath);
}
+static int
+set_noclobber(Char **val)
+{
+ Char *option;
+ int nc = NOCLOBBER_DEFAULT;
+
+ if (val == NULL)
+ return nc;
+ while (*val) {
+ if (*val == 0 || eq(*val, STRRparen))
+ return nc;
+
+ option = *val++;
+
+ if (eq(option, STRnotempty))
+ nc |= NOCLOBBER_NOTEMPTY;
+ else if (eq(option, STRask))
+ nc |= NOCLOBBER_ASK;
+ }
+ return nc;
+}
+
#ifndef lint
/*
* Lint thinks these have null effect
@@ -1301,3 +1350,11 @@ autoset_kanji(void)
}
#endif
#endif
+
+void
+update_wordchars(void)
+{
+ if ((word_chars == STR_WORD_CHARS) || (word_chars == STR_WORD_CHARS_VI)) {
+ word_chars = (VImode ? STR_WORD_CHARS_VI : STR_WORD_CHARS);
+ }
+}