1 |
< |
/* $Header: /home/cvs/src/contrib/tcsh/sh.set.c,v 1.1.1.5 2012-07-08 16:12:18 laffer1 Exp $ */ |
1 |
> |
/* $Header: /p/tcsh/cvsroot/tcsh/sh.set.c,v 3.89 2015/09/08 15:49:53 christos Exp $ */ |
2 |
|
/* |
3 |
|
* sh.set.c: Setting and Clearing of variables |
4 |
|
*/ |
32 |
|
*/ |
33 |
|
#include "sh.h" |
34 |
|
|
35 |
< |
RCSID("$tcsh: sh.set.c,v 3.83 2012/01/15 17:15:28 christos Exp $") |
35 |
> |
RCSID("$tcsh: sh.set.c,v 3.89 2015/09/08 15:49:53 christos Exp $") |
36 |
|
|
37 |
|
#include "ed.h" |
38 |
|
#include "tw.h" |
55 |
|
static void unsetv1 (struct varent *); |
56 |
|
static void exportpath (Char **); |
57 |
|
static void balance (struct varent *, int, int); |
58 |
+ |
static int set_noclobber (Char **); |
59 |
|
|
60 |
|
/* |
61 |
|
* C Shell |
73 |
|
dohash(NULL, NULL); |
74 |
|
} |
75 |
|
} |
76 |
+ |
else if (eq(vp, STRnoclobber)) { |
77 |
+ |
struct varent *p = adrof(STRnoclobber); |
78 |
+ |
if (p == NULL) |
79 |
+ |
stderror(ERR_NAME | ERR_UNDVAR); |
80 |
+ |
else |
81 |
+ |
no_clobber = set_noclobber(p->vec); |
82 |
+ |
} |
83 |
|
else if (eq(vp, STRhistchars)) { |
84 |
|
Char *pn = varval(vp); |
85 |
|
|
173 |
|
noediting = 0; |
174 |
|
/* PWP: add more stuff in here later */ |
175 |
|
} |
176 |
+ |
else if (eq(vp, STRvimode)) { |
177 |
+ |
VImode = 1; |
178 |
+ |
update_wordchars(); |
179 |
+ |
} |
180 |
|
else if (eq(vp, STRshlvl)) { |
181 |
|
tsetenv(STRKSHLVL, varval(vp)); |
182 |
|
} |
207 |
|
else if (eq(vp, STRkillring)) { |
208 |
|
SetKillRing((int)getn(varval(vp))); |
209 |
|
} |
210 |
+ |
else if (eq(vp, STRhistory)) { |
211 |
+ |
sethistory((int)getn(varval(vp))); |
212 |
+ |
} |
213 |
|
#ifndef HAVENOUTMP |
214 |
|
else if (eq(vp, STRwatch)) { |
215 |
|
resetwatch(); |
218 |
|
else if (eq(vp, STRimplicitcd)) { |
219 |
|
implicit_cd = ((eq(varval(vp), STRverbose)) ? 2 : 1); |
220 |
|
} |
221 |
+ |
else if (eq(vp, STRcdtohome)) { |
222 |
+ |
cdtohome = 1; |
223 |
+ |
} |
224 |
|
#ifdef COLOR_LS_F |
225 |
|
else if (eq(vp, STRcolor)) { |
226 |
|
set_color_context(); |
780 |
|
PRCH = tcsh ? '>' : '%'; |
781 |
|
PRCHROOT = '#'; |
782 |
|
} |
783 |
+ |
if (adrof(STRnoclobber) == 0) |
784 |
+ |
no_clobber = 0; |
785 |
|
if (adrof(STRhistlit) == 0) |
786 |
|
HistLit = 0; |
787 |
|
if (adrof(STRloginsh) == 0) |
800 |
|
symlinks = 0; |
801 |
|
if (adrof(STRimplicitcd) == 0) |
802 |
|
implicit_cd = 0; |
803 |
+ |
if (adrof(STRcdtohome) == 0) |
804 |
+ |
cdtohome = 0; |
805 |
|
if (adrof(STRkillring) == 0) |
806 |
|
SetKillRing(0); |
807 |
|
if (did_edit && noediting && adrof(STRedit) == 0) |
808 |
|
noediting = 0; |
809 |
+ |
if (adrof(STRvimode) == 0) |
810 |
+ |
VImode = 0; |
811 |
|
if (did_roe && adrof(STRrecognize_only_executables) == 0) |
812 |
|
tw_cmd_free(); |
813 |
+ |
if (adrof(STRhistory) == 0) |
814 |
+ |
sethistory(0); |
815 |
|
#ifdef COLOR_LS_F |
816 |
|
if (adrof(STRcolor) == 0) |
817 |
|
set_color_context(); |
819 |
|
#if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE) |
820 |
|
update_dspmbyte_vars(); |
821 |
|
#endif |
822 |
+ |
update_wordchars(); |
823 |
|
#ifdef NLS_CATALOGS |
824 |
|
nlsclose(); |
825 |
|
nlsinit(); |
947 |
|
cleanup_until(exppath); |
948 |
|
} |
949 |
|
|
950 |
+ |
static int |
951 |
+ |
set_noclobber(Char **val) |
952 |
+ |
{ |
953 |
+ |
Char *option; |
954 |
+ |
int nc = NOCLOBBER_DEFAULT; |
955 |
+ |
|
956 |
+ |
if (val == NULL) |
957 |
+ |
return nc; |
958 |
+ |
while (*val) { |
959 |
+ |
if (*val == 0 || eq(*val, STRRparen)) |
960 |
+ |
return nc; |
961 |
+ |
|
962 |
+ |
option = *val++; |
963 |
+ |
|
964 |
+ |
if (eq(option, STRnotempty)) |
965 |
+ |
nc |= NOCLOBBER_NOTEMPTY; |
966 |
+ |
else if (eq(option, STRask)) |
967 |
+ |
nc |= NOCLOBBER_ASK; |
968 |
+ |
} |
969 |
+ |
return nc; |
970 |
+ |
} |
971 |
+ |
|
972 |
|
#ifndef lint |
973 |
|
/* |
974 |
|
* Lint thinks these have null effect |
1350 |
|
} |
1351 |
|
#endif |
1352 |
|
#endif |
1353 |
+ |
|
1354 |
+ |
void |
1355 |
+ |
update_wordchars(void) |
1356 |
+ |
{ |
1357 |
+ |
if ((word_chars == STR_WORD_CHARS) || (word_chars == STR_WORD_CHARS_VI)) { |
1358 |
+ |
word_chars = (VImode ? STR_WORD_CHARS_VI : STR_WORD_CHARS); |
1359 |
+ |
} |
1360 |
+ |
} |