NetBSD Problem Report #43255

From dholland@eecs.harvard.edu  Wed May  5 04:44:50 2010
Return-Path: <dholland@eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 8DD7B63BA59
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  5 May 2010 04:44:50 +0000 (UTC)
Message-Id: <20100505044027.99A8CF905@tanaqui.eecs.harvard.edu>
Date: Wed,  5 May 2010 00:40:27 -0400 (EDT)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: sh -n -c doesn't work
X-Send-Pr-Version: 3.95

>Number:         43255
>Category:       bin
>Synopsis:       sh -n -c doesn't work
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 05 04:45:00 +0000 2010
>Closed-Date:    Mon Apr 04 12:37:35 +0000 2016
>Last-Modified:  Mon Apr 04 12:37:35 +0000 2016
>Originator:     David A. Holland
>Release:        NetBSD 5.99.22 (20091208)
>Organization:
>Environment:
System: NetBSD tanaqui 5.99.22 NetBSD 5.99.22 (TANAQUI) #31: Tue Dec 8 22:53:35 EST 2009 dholland@tanaqui:/usr/src/sys/arch/i386/compile/TANAQUI i386
Architecture: i386
Machine: i386

/bin/sh:
     $NetBSD: crt0.c,v 1.17 2007/12/01 10:16:06 yamt Exp $
     $NetBSD: alias.c,v 1.12 2003/08/07 09:05:29 agc Exp $
     $NetBSD: cd.c,v 1.39 2006/05/04 11:16:53 simonb Exp $
     $NetBSD: echo.c,v 1.14 2008/10/12 01:40:37 dholland Exp $
     $NetBSD: error.c,v 1.37 2008/10/16 14:36:40 dholland Exp $
     $NetBSD: eval.c,v 1.98 2009/10/07 18:12:11 christos Exp $
     $NetBSD: exec.c,v 1.42 2008/10/16 15:31:05 dholland Exp $
     $NetBSD: expand.c,v 1.83 2009/11/27 10:50:04 tsutsui Exp $
     $NetBSD: histedit.c,v 1.41 2008/02/13 12:57:16 joerg Exp $
     $NetBSD: input.c,v 1.42 2009/03/10 21:21:11 roy Exp $
     $NetBSD: jobs.c,v 1.68 2008/12/21 17:16:11 christos Exp $
     $NetBSD: mail.c,v 1.16 2003/08/07 09:05:33 agc Exp $
     $NetBSD: main.c,v 1.53 2009/01/18 00:30:54 lukem Exp $
     $NetBSD: memalloc.c,v 1.29 2008/02/15 17:26:06 matt Exp $
     $NetBSD: miscbltin.c,v 1.38 2009/03/29 01:02:49 mrg Exp $
     $NetBSD: mystring.c,v 1.16 2003/08/07 09:05:35 agc Exp $
     $NetBSD: options.c,v 1.41 2009/01/18 00:30:54 lukem Exp $
     $NetBSD: parser.c,v 1.74 2009/01/18 00:30:54 lukem Exp $
     $NetBSD: redir.c,v 1.30 2008/01/21 06:43:03 msaitoh Exp $
     $NetBSD: show.c,v 1.26 2003/11/14 10:46:13 dsl Exp $
     $NetBSD: trap.c,v 1.34 2008/02/15 17:26:06 matt Exp $
     $NetBSD: output.c,v 1.31 2008/10/31 14:38:42 christos Exp $
     $NetBSD: var.c,v 1.39 2008/10/16 14:36:40 dholland Exp $
     $NetBSD: test.c,v 1.37 2008/09/10 19:00:51 christos Exp $
     $NetBSD: kill.c,v 1.26 2009/10/01 09:24:38 spz Exp $
     $NetBSD: syntax.c,v 1.2 2007/12/12 22:55:43 lukem Exp $
     $NetBSD: arith.y,v 1.19 2009/11/13 13:49:09 gson Exp $
     $NetBSD: arith_lex.l,v 1.15 2009/10/29 14:21:40 christos Exp $
     $NetBSD: printf.c,v 1.34 2009/10/13 19:28:31 christos Exp $

>Description:

sh -n doesn't work with sh -c. sh -n is documented as working when not
interactive; -c is not interactive.

>How-To-Repeat:

% sh -n -c 'ls /bad'
ls: /bad: No such file or directory
Exit 1

>Fix:

probably trivial


>Release-Note:

>Audit-Trail:
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/43255 (sh -n -c doesn't work)
Date: Mon, 22 Feb 2016 20:50:21 +0700

 From the PR (summary)
    sh -n doesn't work with sh -c. sh -n is documented as working
    when not interactive; -c is not interactive.

    Fix:
    probably trivial

 It is [trivial] and will be (is now) fixed in the sources I am working from.

 But there is much more wrong with -n than that - it was only barely
 implemented at all (in fact, the src/bin/sh/options.h file has it
 marked as unimplemented, like -b etc)

 I am going to start a thread on tech-userlevel to discuss -n and
 decide just what should be done with it...

 kre


From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43255 CVS commit: src/bin/sh
Date: Mon, 22 Feb 2016 15:03:48 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Mon Feb 22 20:03:48 UTC 2016

 Modified Files:
 	src/bin/sh: eval.c

 Log Message:
 PR/43255: Make -n apply to the -c string so sh -n -c 'commands' works
 as it should. Also, other places where the shell parses strings of
 commands are also now controlled by -n (traps, eval, ...)  (from kre)


 To generate a diff of this commit:
 cvs rdiff -u -r1.111 -r1.112 src/bin/sh/eval.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: wiz@NetBSD.org
State-Changed-When: Mon, 04 Apr 2016 12:37:35 +0000
State-Changed-Why:
Fixed by kre, thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.