NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/54853: unable to 'unset filec' or 'unset edit' in csh



>Number:         54853
>Category:       bin
>Synopsis:       unable to 'unset filec' or 'unset edit' in csh
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 12 03:30:01 +0000 2020
>Originator:     Greg Oster
>Release:        NetBSD 9.0_RC1
>Organization:
>Environment:
System: NetBSD thog 9.0_RC1 NetBSD 9.0_RC1 (GENERIC) #0: Sun Jan 5 16:55:10 CST 2020 oster@thog:/u1/builds/build272/src/obj/amd64/u1/builds/build272/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
It is not currently possible for 'unset filec' or 'unset edit' to actually
unset those variables in csh.  This has been the case for nearly 7 years.

>How-To-Repeat:
 csh -f
 set filec
 unset filec
 *observe that filec is still set*
 set history=20
 set edit
 unset edit
 *observe that edit is still set*

>Fix:
In revision 1.30 of set.c the constructs:
 if (..)
   ..
 if (..)
   ..
were changed to:
 if (..)
   ..
 else if (..)
   ..
breaking the original logic.  Further, with the addition of the history bits,
one needs to guard against attempting to call el_end() or history_end()
with NULL.  

The following patch fixes the 'unset filec' and 'unset edit', restores the 
setting of word_chars, and makes sure el_end() and history_end() are called 
correctly.

Index: set.c
===================================================================
RCS file: /cvsroot/src/bin/csh/set.c,v
retrieving revision 1.35
diff -u -r1.35 set.c
--- set.c       5 Jan 2019 16:54:00 -0000       1.35
+++ set.c       12 Jan 2020 03:14:52 -0000
@@ -518,16 +518,18 @@
        HIST = '!';
        HISTSUB = '^';
     }
-    else if (adrof(STRwordchars) == 0)
+    if (adrof(STRwordchars) == 0)
        word_chars = STR_WORD_CHARS;
 #ifdef FILEC
-    else if (adrof(STRfilec) == 0)
+    if (adrof(STRfilec) == 0)
        filec = 0;
 #endif
 #ifdef EDIT
-    else if (adrof(STRedit) == 0) {
-       el_end(el);
-       history_end(hi);
+    if (adrof(STRedit) == 0) {
+       if (el != NULL)
+           el_end(el);
+       if (hi != NULL)
+           history_end(hi);
        el = NULL;
        hi = NULL;
        editing = 0;



Home | Main Index | Thread Index | Old Index