zsh-users
 help / color / mirror / code / Atom feed
From: Dominik Ritter <dritter03@googlemail.com>
To: zsh-users@zsh.org
Subject: Use glob patterns while reading a file
Date: Thu, 8 Nov 2018 23:53:24 +0100	[thread overview]
Message-ID: <CAJjRh0SROuSoc4f+3bqLNsc+iASx7MRULrNWqdPjK+MKFHys7A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 523 bytes --]

Hi all!

I want to use read one of two files, regardless if it exists or not. My
first approach is to use the alternative glob syntax, but with no luck:
$(< ./(a|b)(N))

Without the subshell, the glob is expanded first, thus it works:
< ./(a|b)(N)

Is it possible to get this to work in conjunction with a subshell?

The usual workarounds are to expand the glob first, and iterate over the
resulting files, test for existance and finally read the contents. This
seems quite cumbersome to me.

Thanks for your help,
Dominik

             reply	other threads:[~2018-11-08 22:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20181108225555epcas2p274de218aef35e46f189ebbfbd9d1892f@epcas2p2.samsung.com>
2018-11-08 22:53 ` Dominik Ritter [this message]
2018-11-09  9:35   ` Peter Stephenson
2018-11-09 14:37     ` Dominik Ritter
2018-11-09 16:20       ` Peter Stephenson
2018-11-10  1:21     ` Daniel Shahaf
2018-11-10  2:07       ` Bart Schaefer
2018-11-10  2:12         ` Bart Schaefer

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=CAJjRh0SROuSoc4f+3bqLNsc+iASx7MRULrNWqdPjK+MKFHys7A@mail.gmail.com \
    --to=dritter03@googlemail.com \
    --cc=zsh-users@zsh.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).