* Force globbing inside of parameter substitution
@ 1999-06-01 12:11 Andrej Borsenkow
1999-06-01 15:36 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Andrej Borsenkow @ 1999-06-01 12:11 UTC (permalink / raw)
To: ZSH workers mailing list
Suppose, I need a list of files sperated by comma. The straightforward way
would be something like
${(j/,/)${:-*}}
Unfortunately, it does not work - it simply results in single `*'.
Using ${(j/,/)$(print *)} does _almost_ wat I'd like ... with two caveats:
1. the file names with spaces are mangled
2. it is potentially less efficient.
Is the use of temporary array the only possibility? (I am mostly interested
in interactive usage, where it should go into one command line).
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.
/andrej
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Force globbing inside of parameter substitution
1999-06-01 12:11 Force globbing inside of parameter substitution Andrej Borsenkow
@ 1999-06-01 15:36 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1999-06-01 15:36 UTC (permalink / raw)
To: Andrej Borsenkow, ZSH workers mailing list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-06-01 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-01 12:11 Force globbing inside of parameter substitution Andrej Borsenkow
1999-06-01 15:36 ` Bart Schaefer
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).