Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Force globbing inside of parameter substitution
- X-seq: zsh-workers 6425
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: "Andrej Borsenkow" <borsenkow.msk@xxxxxx>, "ZSH workers mailing list" <zsh-workers@xxxxxxxxxxxxxx>
- Subject: Re: Force globbing inside of parameter substitution
- Date: Tue, 1 Jun 1999 15:36:43 +0000
- In-reply-to: <001701beac27$d4c820e0$21c9ca95@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <001701beac27$d4c820e0$21c9ca95@xxxxxxxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author