NetBSD Problem Report #54853

From oster@fween.ca  Sun Jan 12 03:27:12 2020
Return-Path: <oster@fween.ca>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 9C1187A1C2
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 12 Jan 2020 03:27:12 +0000 (UTC)
Message-Id: <20200112032710.2311E52D636@thog.fween.ca>
Date: Sat, 11 Jan 2020 21:27:10 -0600 (CST)
From: oster@netbsd.org
Reply-To: oster@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: unable to 'unset filec' or 'unset edit' in csh
X-Send-Pr-Version: 3.95

>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:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 12 03:30:01 +0000 2020
>Closed-Date:    Tue Apr 21 17:06:39 +0000 2020
>Last-Modified:  Tue Apr 21 17:06:39 +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;

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54853 CVS commit: src/bin/csh
Date: Sat, 11 Jan 2020 22:50:30 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Sun Jan 12 03:50:30 UTC 2020

 Modified Files:
 	src/bin/csh: set.c

 Log Message:
 PR/54853: Greg Oster: unable to 'unset filec' or 'unset edit' in csh
 While here allow set edit=vi


 To generate a diff of this commit:
 cvs rdiff -u -r1.35 -r1.36 src/bin/csh/set.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Tue, 21 Apr 2020 17:06:39 +0000
State-Changed-Why:
thanks for the patch. patch committed almost verbatim, so assuming you are ok with it. Feel free to request a pullup if you would like to see this in netbsd-9. thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.