Tue Oct 11 06:31:07 2016 UTC ()
PR 49595 William Ahern: The exit status of "unset NOTSET" should be 0, not 1.
(like 48312 but for ksh)


(dholland)
diff -r1.15 -r1.16 src/bin/ksh/c_sh.c

cvs diff -r1.15 -r1.16 src/bin/ksh/c_sh.c (expand / switch to unified diff)

--- src/bin/ksh/c_sh.c 2013/10/18 19:53:34 1.15
+++ src/bin/ksh/c_sh.c 2016/10/11 06:31:07 1.16
@@ -1,22 +1,22 @@ @@ -1,22 +1,22 @@
1/* $NetBSD: c_sh.c,v 1.15 2013/10/18 19:53:34 christos Exp $ */ 1/* $NetBSD: c_sh.c,v 1.16 2016/10/11 06:31:07 dholland Exp $ */
2 2
3/* 3/*
4 * built-in Bourne commands 4 * built-in Bourne commands
5 */ 5 */
6#include <sys/cdefs.h> 6#include <sys/cdefs.h>
7 7
8#ifndef lint 8#ifndef lint
9__RCSID("$NetBSD: c_sh.c,v 1.15 2013/10/18 19:53:34 christos Exp $"); 9__RCSID("$NetBSD: c_sh.c,v 1.16 2016/10/11 06:31:07 dholland Exp $");
10#endif 10#endif
11 11
12 12
13#include "sh.h" 13#include "sh.h"
14#include "ksh_stat.h" /* umask() */ 14#include "ksh_stat.h" /* umask() */
15#include "ksh_time.h" 15#include "ksh_time.h"
16#include "ksh_times.h" 16#include "ksh_times.h"
17 17
18static char *clocktos ARGS((clock_t t)); 18static char *clocktos ARGS((clock_t t));
19 19
20 20
21/* :, false and true */ 21/* :, false and true */
22int 22int
@@ -681,28 +681,26 @@ c_unset(wp) @@ -681,28 +681,26 @@ c_unset(wp)
681 unset_var = 0; 681 unset_var = 0;
682 break; 682 break;
683 case 'v': 683 case 'v':
684 unset_var = 1; 684 unset_var = 1;
685 break; 685 break;
686 case '?': 686 case '?':
687 return 1; 687 return 1;
688 } 688 }
689 wp += builtin_opt.optind; 689 wp += builtin_opt.optind;
690 for (; (id = *wp) != NULL; wp++) 690 for (; (id = *wp) != NULL; wp++)
691 if (unset_var) { /* unset variable */ 691 if (unset_var) { /* unset variable */
692 struct tbl *vp = global(id); 692 struct tbl *vp = global(id);
693 693
694 if (!(vp->flag & ISSET)) 
695 ret = 1; 
696 if ((vp->flag&RDONLY)) { 694 if ((vp->flag&RDONLY)) {
697 bi_errorf("%s is read only", vp->name); 695 bi_errorf("%s is read only", vp->name);
698 return 1; 696 return 1;
699 } 697 }
700 unset(vp, strchr(id, '[') ? 1 : 0); 698 unset(vp, strchr(id, '[') ? 1 : 0);
701 } else { /* unset function */ 699 } else { /* unset function */
702 if (define(id, NULL)) 700 if (define(id, NULL))
703 ret = 1; 701 ret = 1;
704 } 702 }
705 return ret; 703 return ret;
706} 704}
707 705
708int 706int