* brace expansion question
@ 2005-04-13 1:13 grover mitchell
2005-04-13 4:20 ` Eric Mangold
0 siblings, 1 reply; 5+ messages in thread
From: grover mitchell @ 2005-04-13 1:13 UTC (permalink / raw)
To: zsh-users
I have a file that contains a list like so:
foo1{01..10}
bar2{01..10}
Is there any way to have zsh do a brace expansion on the contents of this file?
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: brace expansion question
2005-04-13 1:13 brace expansion question grover mitchell
@ 2005-04-13 4:20 ` Eric Mangold
2005-04-13 8:03 ` DervishD
0 siblings, 1 reply; 5+ messages in thread
From: Eric Mangold @ 2005-04-13 4:20 UTC (permalink / raw)
To: zsh-users; +Cc: grover mitchell
> I have a file that contains a list like so:
>
> foo1{01..10}
> bar2{01..10}
>
> Is there any way to have zsh do a brace expansion on the contents of this
> file?
>
> Thanks!
>
This is kind of a lame way to do it. Hopefully someone has something
better :)
for word in `cat file`; eval echo $word
I guess you can adapt that to your needs.
Unfortunately, I don't see a parameter expansion flag that performs brace
expansion on the result. It seems like there ought to be one.
Perhaps the "e" flag should also do brace expansion in addition to the
other types of expansion it does. Hmm, there is probably a good reason it
doesn't.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: brace expansion question
2005-04-13 4:20 ` Eric Mangold
@ 2005-04-13 8:03 ` DervishD
2005-04-13 11:18 ` Mariusz Gniazdowski
0 siblings, 1 reply; 5+ messages in thread
From: DervishD @ 2005-04-13 8:03 UTC (permalink / raw)
To: Eric Mangold; +Cc: zsh-users, grover mitchell
Hi Eric and Grover :)
* Eric Mangold <teratorn@world-net.net> dixit:
> > foo1{01..10}
> > bar2{01..10}
> >
> > Is there any way to have zsh do a brace expansion on the contents of this
> > file?
> This is kind of a lame way to do it. Hopefully someone has something
> better :)
>
> for word in `cat file`; eval echo $word
I don't find it lame, but since the file can be quite large, that
expansion could result in a very long command line. Maybe this is
better (untested!!!):
cat file | while read line ; eval print $line
> Unfortunately, I don't see a parameter expansion flag that performs brace
> expansion on the result. It seems like there ought to be one.
I don't remember right now :(
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/
It's my PC and I'll cry if I want to...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: brace expansion question
2005-04-13 8:03 ` DervishD
@ 2005-04-13 11:18 ` Mariusz Gniazdowski
2005-04-13 16:05 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Mariusz Gniazdowski @ 2005-04-13 11:18 UTC (permalink / raw)
To: zsh-users; +Cc: Eric Mangold, grover mitchell
Day Wed, Apr 13, 2005 at 10:03:15AM +0200, DervishD:
> cat file | while read line ; eval print $line
It can be done without cat:
{ while read line ; eval print $line } < file
--
Mariusz Gniazdowski
----------------------------------------------------------------------
Startuj z INTERIA.PL! >>> http://link.interia.pl/f186c
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: brace expansion question
2005-04-13 11:18 ` Mariusz Gniazdowski
@ 2005-04-13 16:05 ` Bart Schaefer
0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2005-04-13 16:05 UTC (permalink / raw)
To: zsh-users
On Apr 12, 6:13pm, grover mitchell wrote:
}
} foo1{01..10}
} bar2{01..10}
}
} Is there any way to have zsh do a brace expansion on the contents of
} this file?
On Apr 13, 2:20pm, Eric Mangold wrote:
}
} Unfortunately, I don't see a parameter expansion flag that performs
} brace expansion on the result. It seems like there ought to be one.
Paramter expansion happens before brace expansion in normal evaluation
order, so it'd be sufficient if the tilde flag made braces eligible for
interpretation as it does with glob metacharacters. The reason it does
not is mostly historical, but also for compatibility bash. (I notice
that tcsh expands braces that result from parameter expansion.)
} Perhaps the "e" flag should also do brace expansion [...] there is
} probably a good reason it doesn't.
The operations enabled by (e) all have the same evaluation order as
parameter expansion (that is, they're done left to right as the parser
encounters them).
On Apr 13, 1:18pm, Mariusz Gniazdowski wrote:
} Subject: Re: brace expansion question
}
} Day Wed, Apr 13, 2005 at 10:03:15AM +0200, DervishD:
} > cat file | while read line ; eval print $line
}
} It can be done without cat:
} { while read line ; eval print $line } < file
Or even
while read line; do eval print $line; done < file
(which doesn't require the SHORT_LOOPS setopt).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-04-13 16:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-13 1:13 brace expansion question grover mitchell
2005-04-13 4:20 ` Eric Mangold
2005-04-13 8:03 ` DervishD
2005-04-13 11:18 ` Mariusz Gniazdowski
2005-04-13 16:05 ` 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).