Re: a small SBCL question
- From: Zach Beane <xach@xxxxxxxx>
- Date: 29 Dec 2006 20:03:49 -0500
dneu@xxxxxxx writes:
Pascal Bourguignon wrote:
S/CL-USER[39]> (with-open-stream (files
(sb-ext:process-output
(sb-ext:run-program "/bin/ls" '("-l" "/tmp/a.lisp")
:output :stream)))
(loop :for line = (read-line files nil nil)
:while line :do (princ line) (terpri)))
-rw-r--r-- 1 pjb pjb 93 2006-12-13 21:21 /tmp/a.lisp
NIL
I tried the example above, with a wildcard, i.e. "/tmp/*.lisp" instead
of "/tmp/a.lisp",
and no files were found, and there are files matching the pattern.
Could someone explain why?
Wildcard expansion is done by the shell, not by programs like "ls"
(most of the time, anyway). RUN-PROGRAM uses something like exec(2) to
run programs. If you wanted shell-style wildcard expansion, you'd have
to run a shell:
(sb-ext:run-program "/bin/sh" (list "-c" "/tmp/*.lisp"))
At that point, the argument after "-c" should consist of *all* your
arguments serialized to a string, for the shell to deserialize into
separate arguments. This is error-prone due to quoting and shell
metacharacters and the like. Normal SBCL RUN-PROGRAM doesn't have any
of that trouble since it uses exec directly.
Zach
.
- Follow-Ups:
- Re: a small SBCL question
- From: Zach Beane
- Re: a small SBCL question
- References:
- a small SBCL question
- From: TorvoSollazzo@xxxxxxxxxxxx
- Re: a small SBCL question
- From: Pascal Bourguignon
- Re: a small SBCL question
- From: dneu
- a small SBCL question
- Prev by Date: Re: a small SBCL question
- Next by Date: Re: a small SBCL question
- Previous by thread: Re: a small SBCL question
- Next by thread: Re: a small SBCL question
- Index(es):
Relevant Pages
|
|