NetBSD Problem Report #39466
From cheusov@tut.by Fri Sep 5 21:54:17 2008
Return-Path: <cheusov@tut.by>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id F34F263B11D
for <gnats-bugs@gnats.netbsd.org>; Fri, 5 Sep 2008 21:54:16 +0000 (UTC)
Message-Id: <s93sksei7ij.fsf@chen.chizhovka.net>
Date: Sat, 06 Sep 2008 00:53:56 +0300
From: cheusov@tut.by
Reply-To:
To: gnats-bugs@gnats.NetBSD.org
Subject: /bin/sh: eval and redirections
X-Send-Pr-Version: 3.95
>Number: 39466
>Category: bin
>Synopsis: /bin/sh: eval and bad redirections
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kre
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Sep 05 21:55:00 +0000 2008
>Closed-Date: Thu May 25 05:07:27 +0000 2017
>Last-Modified: Thu May 25 05:07:27 +0000 2017
>Originator: cheusov@tut.by
>Release: NetBSD 4.0_STABLE
>Organization:
>Environment:
System: NetBSD chen.chizhovka.net 4.0_STABLE NetBSD 4.0_STABLE (GENERIC) #0: Wed Jul 16 00:28:58 EEST 2008 cheusov@chen.chizhovka.net:/srv/obj/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
Exit status of eval with bad redirection
~>bash -c 'eval "cat > /path/to/file"; echo $?'
bash: line 1: /path/to/file: No such file or directory
1
~>zsh -c 'eval "cat > /path/to/file"; echo $?'
zsh: no such file or directory: /path/to/file
1
~>ksh -c 'eval "cat > /path/to/file"; echo $?'
ksh: cannot create /path/to/file: No such file or directory
1
~>zsh -c 'eval "cat > /path/to/file"; echo $?'
zsh: no such file or directory: /path/to/file
1
~>mksh -c 'eval "cat > /path/to/file"; echo $?'
mksh: cannot create /path/to/file: No such file or directory
1
~>dash -c 'eval "cat > /path/to/file"; echo $?'
eval: 1: cannot create /path/to/file: Directory nonexistent
2
~>/usr/pkg/heirloom/bin/sh -c 'eval "cat > /path/to/fi>
/usr/pkg/heirloom/bin/sh: /path/to/file: cannot create
1
~>/bin/sh -c 'eval "cat > /path/to/file"; echo $?'
eval: cannot create /path/to/file: directory nonexistent
=> 0
~>
And 'set -e' too
0 ~>/usr/pkg/heirloom/bin/sh /home/cheusov/tmp/1.sh
/home/cheusov/tmp/1.sh: /path/to/bad/file.txt: cannot create
1 ~>/bin/ksh /home/cheusov/tmp/1.sh
/home/cheusov/tmp/1.sh: cannot create /path/to/bad/file.txt: No such file or directory
1 ~>mksh /home/cheusov/tmp/1.sh
/home/cheusov/tmp/1.sh: cannot create /path/to/bad/file.txt: No such file or directory
1 ~>dash /home/cheusov/tmp/1.sh
eval: 1: cannot create /path/to/bad/file.txt: Directory nonexistent
2 ~>zsh /home/cheusov/tmp/1.sh
(eval):1: no such file or directory: /path/to/bad/file.txt
1 ~>bash /home/cheusov/tmp/1.sh
/home/cheusov/tmp/1.sh: line 1: /path/to/bad/file.txt: No such file or directory
1 ~>/bin/sh /home/cheusov/tmp/1.sh
eval: cannot create /path/to/bad/file.txt: directory nonexistent
=> This should not happen!
=> 0 ~>cat /home/cheusov/tmp/1.sh
#!/bin/sh
set -e
eval 'cat > /path/to/bad/file.txt'
echo "This should not happen!"
0 ~>
>How-To-Repeat:
>Fix:
Unknown
>Release-Note:
>Audit-Trail:
From: Aleksey Cheusov <cheusov@tut.by>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/39466: /bin/sh: eval and redirections
Date: Fri, 31 Oct 2008 22:30:05 +0200
I think this bug is more serious than I thought before.
~>cat /home/cheusov/tmp/1.sh
#!/bin/sh
cat < /dev/null > /not/exist
echo $?
~>/home/cheusov/tmp/1.sh
/home/cheusov/tmp/1.sh: cannot create /not/exist: directory nonexistent
0
~>
HINT: commands that do not need fork (built-ins, like echo, printf etc.)
work properly.
--
Best regards, Aleksey Cheusov.
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/39466 (/bin/sh: eval and redirections)
Date: Mon, 22 Feb 2016 05:12:42 +0700
I believe this bug is now fixed, and this PR can be closed.
Do you agree?
kre
State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 23 Apr 2016 21:59:22 +0000
State-Changed-Why:
A question was asked.
(namely: we think this is fixed; ok to close?)
Responsible-Changed-From-To: bin-bug-people->kre
Responsible-Changed-By: kre@NetBSD.org
Responsible-Changed-When: Fri, 13 May 2016 02:37:55 +0000
Responsible-Changed-Why:
I am (for now) handling this PR
State-Changed-From-To: feedback->analyzed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Fri, 13 May 2016 02:37:55 +0000
State-Changed-Why:
This and PR bin/47065 turn out to be the same bug. I have a tentative
fix, but it needs a lot of testing before I will be confident in it.
From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/39466 CVS commit: src/bin/sh
Date: Wed, 1 Jun 2016 02:50:03 +0000
Module Name: src
Committed By: kre
Date: Wed Jun 1 02:50:03 UTC 2016
Modified Files:
src/bin/sh: error.c
Log Message:
PR bin/47065 PR bin/39466
When the shell exits after an error (when that is the right thing for
it to do) ensure that it never does exit(0).
To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/bin/sh/error.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: analyzed->feedback
State-Changed-By: kre@NetBSD.org
State-Changed-When: Wed, 01 Jun 2016 05:19:31 +0000
State-Changed-Why:
This should be fixed now, in current, can you confirm?
State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Thu, 25 May 2017 05:07:27 +0000
State-Changed-Why:
Feedback timeout.
>Unformatted:
(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-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.