On Sun, 15 Apr 2018, Martijn Dekker wrote:
> Op 15-04-18 om 03:41 schreef Philip Guenther:
> > On Sun, 15 Apr 2018, Klemens Nanni wrote:
> > > It also badly effects non-empty cases:
> > ...
> > >   $ ./obj/ksh -c alias
> > >   autoload=''
> > >   functions=''
> > 
> > Hah!  The original diff i actually broken (it tests the wrong variable)
> > but I fixed that by accident when I manually made the diff in my tree!
> > 
> > So, uh, I'm no longer fine with the original diff...
> 
> D'oh!
> 
> That's embarrassing. Sorry about that. :-/
...
> --- misc.c    9 Apr 2018 17:53:36 -0000       1.70
> +++ misc.c    15 Apr 2018 02:06:55 -0000
> @@ -966,6 +966,12 @@ print_value_quoted(const char *s)
>       const char *p;
>       int inquote = 0;
> 
> +     /* Check for empty */
> +     if (!*s) {
> +             shprintf("''");
> +             return;
> +     }
> +

This thread was never resolved/committed.  Looking again at the diffs, I 
still think I prefer that we _not_ touch print_value_quoted(), as the 
other callers all use the 'key=value' format and don't need special 
handling of empty values, leaving a diff like the one below.

ok?

Philip


Index: bin/ksh/c_sh.c
===================================================================
RCS file: /data/src/openbsd/src/bin/ksh/c_sh.c,v
retrieving revision 1.63
diff -u -p -r1.63 c_sh.c
--- bin/ksh/c_sh.c      9 Apr 2018 17:53:36 -0000       1.63
+++ bin/ksh/c_sh.c      30 Dec 2018 22:24:19 -0000
@@ -478,7 +478,10 @@ c_trap(char **wp)
                for (p = sigtraps, i = NSIG+1; --i >= 0; p++) {
                        if (p->trap != NULL) {
                                shprintf("trap -- ");
-                               print_value_quoted(p->trap);
+                               if (p->trap[0])
+                                       print_value_quoted(p->trap);
+                               else
+                                       shprintf("''");
                                shprintf(" %s\n", p->name);
                        }
                }
Index: regress/bin/ksh/obsd-regress.t
===================================================================
RCS file: /data/src/openbsd/src/regress/bin/ksh/obsd-regress.t,v
retrieving revision 1.10
diff -u -p -r1.10 obsd-regress.t
--- regress/bin/ksh/obsd-regress.t      8 Dec 2018 21:03:51 -0000       1.10
+++ regress/bin/ksh/obsd-regress.t      30 Dec 2018 22:41:27 -0000
@@ -503,3 +503,20 @@ description:
 stdin:
        kill -s SIGINFO $$
 ---
+
+name: trap-ignore-output
+description:
+       trap output shows ignored signals correctly
+stdin:
+       trap '' SIGUSR1 SIGUSR2
+       trap "" SIGPIPE
+       trap exit SIGINT
+       trap exit\ 1 SIGTERM
+       trap
+expected-stdout:
+       trap -- exit INT
+       trap -- '' PIPE
+       trap -- 'exit 1' TERM
+       trap -- '' USR1
+       trap -- '' USR2
+---

Reply via email to