Created
February 3, 2018 13:41
-
-
Save aw/23e5a33d1254a40b80b2c1fc94af5f47 to your computer and use it in GitHub Desktop.
Revisions
-
aw created this gist
Feb 3, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ 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: ```bash grep -l "let" * ``` ### 1. with (cons) This method prints the results, but you can actually do anything you want with the output `(line T)` ```picolisp (in (cons 'grep "-l" "let" (dir ".")) (until (eof) (prinl (line T)) ) ) ``` ### 2. with (apply) This method simply executes the command and returns the result of the `(call)`: `T` or `NIL` ```picolisp (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.