In PicoLisp, there is often a situation where you want to execute a command with the *
argument.
Bash shell expands *
to the list of filenames, but PicoLisp doesn't.
Here are two workarounds for this bash command:
grep -l "let" *
This method prints the results, but you can actually do anything you want with the output (line T)
(in
(cons 'grep "-l" "let" (dir "."))
(until (eof)
(prinl (line T)) ) )
This method simply executes the command and returns the result of the (call)
: T
or NIL
(apply call (dir ".") "grep" "-l" "let")
Note: In both cases, the grep
command will only run once. It's not being called once for every file, as in a loop or iteration. In other words, it's efficient.