Source-Changes-HG archive

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

[src/trunk]: src/bin/sh TOG require that 'set +o' output the options in a for...



details:   https://anonhg.NetBSD.org/src/rev/d566f769975a
branches:  trunk
changeset: 586318:d566f769975a
user:      dsl <dsl%NetBSD.org@localhost>
date:      Tue Dec 13 17:44:18 2005 +0000

description:
TOG require that 'set +o' output the options in a form suitable for
restoring them - make it so.

diffstat:

 bin/sh/expand.c  |   6 +++---
 bin/sh/options.c |  22 ++++++++++++++++------
 bin/sh/options.h |   4 ++--
 3 files changed, 21 insertions(+), 11 deletions(-)

diffs (88 lines):

diff -r 2b365b998522 -r d566f769975a bin/sh/expand.c
--- a/bin/sh/expand.c   Tue Dec 13 16:54:21 2005 +0000
+++ b/bin/sh/expand.c   Tue Dec 13 17:44:18 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expand.c,v 1.71 2005/06/01 15:41:19 lukem Exp $        */
+/*     $NetBSD: expand.c,v 1.72 2005/12/13 17:44:18 dsl Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)expand.c   8.5 (Berkeley) 5/15/95";
 #else
-__RCSID("$NetBSD: expand.c,v 1.71 2005/06/01 15:41:19 lukem Exp $");
+__RCSID("$NetBSD: expand.c,v 1.72 2005/12/13 17:44:18 dsl Exp $");
 #endif
 #endif /* not lint */
 
@@ -866,7 +866,7 @@
                break;
        case '-':
                for (i = 0; optlist[i].name; i++) {
-                       if (optlist[i].val)
+                       if (optlist[i].val && optlist[i].letter)
                                STPUTC(optlist[i].letter, expdest);
                }
                break;
diff -r 2b365b998522 -r d566f769975a bin/sh/options.c
--- a/bin/sh/options.c  Tue Dec 13 16:54:21 2005 +0000
+++ b/bin/sh/options.c  Tue Dec 13 17:44:18 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options.c,v 1.39 2005/07/15 17:46:54 christos Exp $    */
+/*     $NetBSD: options.c,v 1.40 2005/12/13 17:44:18 dsl Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)options.c  8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: options.c,v 1.39 2005/07/15 17:46:54 christos Exp $");
+__RCSID("$NetBSD: options.c,v 1.40 2005/12/13 17:44:18 dsl Exp $");
 #endif
 #endif /* not lint */
 
@@ -221,10 +221,20 @@
        int i;
 
        if (name == NULL) {
-               out1str("Current option settings\n");
-               for (i = 0; i < NOPTS; i++)
-                       out1fmt("%-16s%s\n", optlist[i].name,
-                               optlist[i].val ? "on" : "off");
+               if (val) {
+                       out1str("Current option settings\n");
+                       for (i = 0; i < NOPTS; i++) {
+                               out1fmt("%-16s%s\n", optlist[i].name,
+                                       optlist[i].val ? "on" : "off");
+                       }
+               } else {
+                       out1str("set");
+                       for (i = 0; i < NOPTS; i++) {
+                               out1fmt(" %co %s",
+                                       "+-"[optlist[i].val], optlist[i].name);
+                       }
+                       out1str("\n");
+               }
        } else {
                for (i = 0; i < NOPTS; i++)
                        if (equal(name, optlist[i].name)) {
diff -r 2b365b998522 -r d566f769975a bin/sh/options.h
--- a/bin/sh/options.h  Tue Dec 13 16:54:21 2005 +0000
+++ b/bin/sh/options.h  Tue Dec 13 17:44:18 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options.h,v 1.18 2005/05/07 19:52:17 dsl Exp $ */
+/*     $NetBSD: options.h,v 1.19 2005/12/13 17:44:18 dsl Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -48,7 +48,7 @@
        const char *name;               /* for set -o <name> */
        const char letter;              /* set [+/-]<letter> and $- */
        const char opt_set;             /* mutually exclusive option set */
-       char val;                       /* value of <letter>flag */
+       unsigned char val;              /* value of <letter>flag */
 };
 
 /* Those marked [U] are required by posix, but have no effect! */



Home | Main Index | Thread Index | Old Index