Austin Group Defect Tracker

Aardvark Mark III


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001232 [1003.1(2016)/Issue7+TC2] Shell and Utilities Objection Enhancement Request 2019-03-02 23:35 2019-03-02 23:35
Reporter stephane View Status public  
Assigned To
Priority normal Resolution Open  
Status New  
Name Stephane Chazelas
Organization
User Reference
Section Shell redirection
Page Number 2361
Line Number 75317-75319
Interp Status ---
Final Accepted Text
Summary 0001232: redirection to wildcard that match more than one word
Description > Pathname expansion shall not be performed on the word by a
> non-interactive shell; an interactive shell may perform it,
> but shall do so only when the expansion would result in one
> word.

That wording matches the behaviour of ksh88 or pdksh, but not
that of bash or ksh93, which when the expansion would result in
more than one word fail the redirected command with an
"ambiguous redirect" error instead of leaving the wildcard
unexpanded (which IMO, is slightly saner).

zsh does a tee-like redirection in cmd > * and a cat-like input
redirection in cmd < *, but not when in sh mode.
Desired Action Change to:

> Pathname expansion shall not be performed on the word by a
> non-interactive shell; an interactive shell may perform it
> but if the expansion would result in more than one word, the
> behaviour is unspecified.


Related: ksh88 does that expansion even when non-interactive. As
the POSIX specification deviates from that reference
implementation, it would be useful to add a "rationale" section
stating it clearly and add a test case to the conformance test
suite as there are still many certified systems that are not
compliant in that regard.

It's quite serious as it means that code like cmd > $file could
end up redirecting to a different file from the one stored in
$file even though POSIX guarantees it should not.

That's why in practice we also need to quote parameter expansions
and command substitutions in the target of redirections even in
scripts (for ksh88, but also for bash when not in sh mode).
Tags No tags attached.
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2019-03-02 23:35 stephane New Issue
2019-03-02 23:35 stephane Name => Stephane Chazelas
2019-03-02 23:35 stephane Section => Shell redirection
2019-03-02 23:35 stephane Page Number => 2361
2019-03-02 23:35 stephane Line Number => 75317-75319


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker