I wanted to pass the results of an "ls" command to a certain variable.
So, I used the following syntax:
set x [exec ls *.tcl]
But, unfortunately it didn't work. And, when I viewed some examples
for "exec" command on the web, I found I should write it in the
following syntax:
set x [exec ls {*} [glob *.tcl]]
Can any one explain to me why using the asterisk wild card with "exec"
required to write this command like that instead of the first command
I wrote above?
usually you get the "glob"ing from the shell. ( but find forex has its own globing )
In your case the following would be sufficient
set x [exec ls [glob *.tcl]]
as an alternative you can exec the shell to run your ls command:
exec $::env(SHELL) -c {ls -l *}
now try find:
exec find . -name * -printf {%m %n % 8s %u %g %p \n}
uwe
Take care with the {*} syntax: no space between the splat and the list
being expanded:
set x [exec ls {*}[glob *.tcl]]
--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous
uwe
Others have explained about globing being a shell property.
I'd like to point out you do not need exec or ls at all, you could just do:
set x [glob *.tcl]
If you want any of the details that some of the switches to ls provide, you
can get them via the file command.
--
+------------------------------------------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
> Take care with the {*} syntax: no space between the splat and the list
> being expanded:
Ahhhh, yes, this new feature.... Can someone provide a link to the
description of this newish tcl feature, as all the searching I've
tried using all varieties of {*} have not worked for me.
I understand it's basic idea, I just can't find the syntax rules, such
as the statement above saying it can't have spaces.....
thanks