All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jilles Tjoelker <jilles@stack.nl>
To: Jack Bates <i72aoc@nottheoilrig.com>
Cc: dash@vger.kernel.org
Subject: Re: glob pattern and redirected input file name
Date: Fri, 30 Aug 2013 16:34:22 +0200	[thread overview]
Message-ID: <20130830143422.GA12474@stack.nl> (raw)
In-Reply-To: <521FDDF8.5010200@nottheoilrig.com>

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

      reply	other threads:[~2013-08-30 14:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-29 23:49 glob pattern and redirected input file name Jack Bates
2013-08-30 14:34 ` Jilles Tjoelker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130830143422.GA12474@stack.nl \
    --to=jilles@stack.nl \
    --cc=dash@vger.kernel.org \
    --cc=i72aoc@nottheoilrig.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.