zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: "Andrej Borsenkow" <borsenkow.msk@sni.de>,
	"ZSH workers mailing list" <zsh-workers@sunsite.auc.dk>
Subject: Re: Force globbing inside of parameter substitution
Date: Tue, 1 Jun 1999 15:36:43 +0000	[thread overview]
Message-ID: <990601153644.ZM11011@candle.brasslantern.com> (raw)
In-Reply-To: <001701beac27$d4c820e0$21c9ca95@mow.siemens.ru>

On Jun 1,  4:11pm, Andrej Borsenkow wrote:
} Subject: Force globbing inside of parameter substitution
}
} Suppose, I need a list of files sperated by comma.

	"${(j/,/)${(f)$(print -rl -- *)}}"

You probably don't need the `-r' or the `--', but I'm paranoid.

} ${(j/,/)${:-*}}
} 
} Unfortunately, it does not work - it simply results in single `*'.

Yes ... filename generation always happens after parameter expansion.

} As a side note: it looks, like GLOB_SUBST does not apply in the above case.
} I have globsubst off, but the result of ${:-*} is still globbed. Is it
} intentional? I would deem it as a bug.

The stuff on the RHS of :- (and :+ etc.) is treated as if it were outside
the ${ } for purposes of tokenization.  That's why POSIX permits quotes
to appear inside the braces: so you can do stuff like ${1+"$@"}.  I should
have remembered that when I brought up quoting yesterday.

Interestingly, ${(e):-*} produces an untokenized * (which is not globbed).
I'd be more inclined to call _that_ a bug.

} Using ${(j/,/)$(print *)} does _almost_ wat I'd like ... with two caveats:
} 
} 1. the file names with spaces are mangled

Quoting and print -rl should deal with that.  You don't have any file
names with newlines, do you?

} 2. it is potentially less efficient.

Yes.

} Is the use of temporary array the only possibility?

The only way to avoid a $(...), yes.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


      reply	other threads:[~1999-06-01 15:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-01 12:11 Andrej Borsenkow
1999-06-01 15:36 ` Bart Schaefer [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=990601153644.ZM11011@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=borsenkow.msk@sni.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).