* glob pattern and redirected input file name
@ 2013-08-29 23:49 Jack Bates
2013-08-30 14:34 ` Jilles Tjoelker
0 siblings, 1 reply; 2+ messages in thread
From: Jack Bates @ 2013-08-29 23:49 UTC (permalink / raw)
To: dash
What is DASH supposed to do when input is redirected from a file, and
the file name is a glob pattern? e.g.
tar xz < foo-*.tar.gz
Is it supposed to expand the glob pattern, or is that not supported?
The following both work, is there a better workaround?
tar fxz foo-*.tar.gz
tar xz < $(echo foo-*.tar.gz)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: glob pattern and redirected input file name
2013-08-29 23:49 glob pattern and redirected input file name Jack Bates
@ 2013-08-30 14:34 ` Jilles Tjoelker
0 siblings, 0 replies; 2+ messages in thread
From: Jilles Tjoelker @ 2013-08-30 14:34 UTC (permalink / raw)
To: Jack Bates; +Cc: dash
On Thu, Aug 29, 2013 at 04:49:12PM -0700, Jack Bates wrote:
> What is DASH supposed to do when input is redirected from a file,
> and the file name is a glob pattern? e.g.
> tar xz < foo-*.tar.gz
> Is it supposed to expand the glob pattern, or is that not supported?
Per POSIX XCU 2.7 Redirection, pathname generation may (but need not) be
performed on the word after a redirection operator other than << or <<-
if the shell is interactive and one word would result.
Dash chooses the option that results in the smallest code: never
performing pathname generation in this case.
> The following both work, is there a better workaround?
> tar fxz foo-*.tar.gz
> tar xz < $(echo foo-*.tar.gz)
These are both concise methods. The former's problem is that it does
something strange if more than one file matches. The second has problems
with pathnames starting with '-', containing backslashes or ending with
newlines.
In a script you might do
set -- foo-*.tar.gz
if [ "$#" -ne 1 ] || [ ! -f "$1" ]; then
echo "Bad wildcard"
exit 2
fi
tar -xzf "$1"
--
Jilles Tjoelker
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-08-30 14:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-29 23:49 glob pattern and redirected input file name Jack Bates
2013-08-30 14:34 ` Jilles Tjoelker
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.