Thu Feb 14 13:27:59 2019 UTC ()
DEBUG mode only change.   When pretty-printing a word from a parse
tree, don't display a CTLESC which is there only to protect a CTL*
char (a data char that happens to have the same value).  No actual
CTL* chars are printed as data, so no escaping is needed to protect
data which just happens to look the same.  Dropping this avoids the
possibility of confusion/ambiguity in what the word actually contains.

NFC for any normal shell build (very little of this file gets compiled there)


(kre)
diff -r1.52 -r1.53 src/bin/sh/show.c

cvs diff -r1.52 -r1.53 src/bin/sh/show.c (expand / switch to unified diff)

--- src/bin/sh/show.c 2019/01/22 13:48:28 1.52
+++ src/bin/sh/show.c 2019/02/14 13:27:59 1.53
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: show.c,v 1.52 2019/01/22 13:48:28 kre Exp $ */ 1/* $NetBSD: show.c,v 1.53 2019/02/14 13:27:59 kre Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved. 7 * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
8 * 8 *
9 * This code is derived from software contributed to Berkeley by 9 * This code is derived from software contributed to Berkeley by
10 * Kenneth Almquist. 10 * Kenneth Almquist.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38#ifndef lint 38#ifndef lint
39#if 0 39#if 0
40static char sccsid[] = "@(#)show.c 8.3 (Berkeley) 5/4/95"; 40static char sccsid[] = "@(#)show.c 8.3 (Berkeley) 5/4/95";
41#else 41#else
42__RCSID("$NetBSD: show.c,v 1.52 2019/01/22 13:48:28 kre Exp $"); 42__RCSID("$NetBSD: show.c,v 1.53 2019/02/14 13:27:59 kre Exp $");
43#endif 43#endif
44#endif /* not lint */ 44#endif /* not lint */
45 45
46#include <stdio.h> 46#include <stdio.h>
47#include <stdarg.h> 47#include <stdarg.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <unistd.h> 49#include <unistd.h>
50#include <fcntl.h> 50#include <fcntl.h>
51#include <errno.h> 51#include <errno.h>
52#include <limits.h> 52#include <limits.h>
53 53
54#include <sys/types.h> 54#include <sys/types.h>
55#include <sys/uio.h> 55#include <sys/uio.h>
@@ -635,27 +635,28 @@ sharg(union node *arg, TFILE *fp) @@ -635,27 +635,28 @@ sharg(union node *arg, TFILE *fp)
635 int subtype = 0; 635 int subtype = 0;
636 int quoted = 0; 636 int quoted = 0;
637 637
638 if (arg->type != NARG) { 638 if (arg->type != NARG) {
639 asprintf(&s, "<node type %d> ! NARG\n", arg->type); 639 asprintf(&s, "<node type %d> ! NARG\n", arg->type);
640 trace_puts(s, fp); 640 trace_puts(s, fp);
641 abort(); /* no need to free s, better not to */ 641 abort(); /* no need to free s, better not to */
642 } 642 }
643 643
644 bqlist = arg->narg.backquote; 644 bqlist = arg->narg.backquote;
645 for (p = arg->narg.text ; *p ; p++) { 645 for (p = arg->narg.text ; *p ; p++) {
646 switch (*p) { 646 switch (*p) {
647 case CTLESC: 647 case CTLESC:
648 trace_putc('\\', fp); 648 if (BASESYNTAX[p[1]] != CCTL)
 649 trace_putc('\\', fp);
649 trace_putc(*++p, fp); 650 trace_putc(*++p, fp);
650 break; 651 break;
651 652
652 case CTLNONL: 653 case CTLNONL:
653 trace_putc('\\', fp); 654 trace_putc('\\', fp);
654 trace_putc('\n', fp); 655 trace_putc('\n', fp);
655 break; 656 break;
656 657
657 case CTLVAR: 658 case CTLVAR:
658 subtype = *++p; 659 subtype = *++p;
659 if (!quoted != !(subtype & VSQUOTE)) 660 if (!quoted != !(subtype & VSQUOTE))
660 trace_putc('"', fp); 661 trace_putc('"', fp);
661 trace_putc('$', fp); 662 trace_putc('$', fp);