NetBSD Problem Report #37494
From riz@netbsd.localdomain Thu Dec 6 21:54:57 2007
Return-Path: <riz@netbsd.localdomain>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id EF36E63B946
for <gnats-bugs@gnats.NetBSD.org>; Thu, 6 Dec 2007 21:54:56 +0000 (UTC)
Message-Id: <20071206071328.BE8D31BF0EA@netbsd.localdomain>
Date: Wed, 5 Dec 2007 23:13:28 -0800 (PST)
From: riz@netbsd.org
Reply-To: riz@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: sh doesn't glob input redirect filenames as expected
X-Send-Pr-Version: 3.95
>Number: 37494
>Category: bin
>Synopsis: /bin/sh doesn't expand * in filenames for input redirection.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Dec 06 21:55:01 +0000 2007
>Closed-Date: Sun Jun 12 01:13:04 +0000 2016
>Last-Modified: Sun Jun 12 01:13:04 +0000 2016
>Originator: riz@netbsd.org
>Release: NetBSD 4.99.38
>Organization:
>Environment:
System: NetBSD netbsd.localdomain 4.99.38 NetBSD 4.99.38 (PUFFS) #1: Sat Dec 1 19:29:09 PST 2007 riz@netbsd.localdomain:/home/riz/obj/sys/arch/amd64/compile/PUFFS amd64
Architecture: x86_64
Machine: amd64
>Description:
Even if a file '/tmp/xyz' exists, "cat </tmp/xyz*" doesn't
redirect input from it:
$ cat < /tmp/xyz*
sh: cannot open /tmp/xyz*: no such file
/bin/ksh and /bin/csh both work as expected, here, and SUSv2 says:
Redirecting Input
Input redirection will cause the file whose name results from the expansion of word to be opened for reading on the designated file descriptor, or standard input if the file descriptor is not specified.
>How-To-Repeat:
/bin/sh
echo "123" > /tmp/xyz # assume no other filenames in /tmp begin with "xyz"
cat </tmp/xyz*
>Fix:
None given.
>Release-Note:
>Audit-Trail:
From: Shaun Zinck <shaun.zinck@gmail.com>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/37494
Date: Tue, 3 Jun 2008 16:57:19 -0500
Also in SUSv2, about 5 lines up from your quote:
Redirection
Pathname expansion will not be performed on the word by a
non-interactive shell; an interactive shell may perform it, but will do
so only when the expansion would result in one word.
It looks like this should only be expanded in interactive shells.
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/37494
Date: Sat, 19 Sep 2009 19:24:54 +0000
On Wed, Jun 04, 2008 at 02:40:01AM +0000, Shaun Zinck wrote:
> Also in SUSv2, about 5 lines up from your quote:
>
> Redirection
>
> Pathname expansion will not be performed on the word by a
> non-interactive shell; an interactive shell may perform it, but will do
> so only when the expansion would result in one word.
>
>
> It looks like this should only be expanded in interactive shells.
I tend to think that interactive and non-interactive shells shouldn't
behave differently in things like this. Particularly for sh. How badly
do we want this feature?
--
David A. Holland
dholland@netbsd.org
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/37494 (/bin/sh doesn't expand * in filenames for input redirection.)
Date: Mon, 22 Feb 2016 01:38:35 +0700
POSIX is in (exact) accord with what was quoted from SUSv2,
non-interactive shells may not perform pathname expansion on
redirection file names, interactive shells may, but are not
required to.
It has long been a "feature" of the Bourne shell that it acted
this way - shells with a greater emphasis on the interactive
user experience have changed it (because it is nice to be able
to type less).
But since nothing has happened to change sh in the past 8
years, and there really doesn't seem to be a huge demand for it
to be changed, I think this PR should just be closed, with an
"it is how it is, and it's staying that way" explanation.
kre
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 12 Jun 2016 01:13:04 +0000
State-Changed-Why:
Expanding * in filenames for input redirection is not allowed unless
the shell is interactive, and we don't think having the shell behave
differently when interactive is desirable.
>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.