[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Split string into shell words?
From: |
Kai Grossjohann |
Subject: |
Re: Split string into shell words? |
Date: |
Wed, 28 Jan 2004 09:37:18 +0100 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.2 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> It's pretty nasty to do it right:
>
> foo "bar $(baz "toto") titi"
>
> should turn into "foo" "bar $(baz \"toto\") titi".
> What do you need this for ?
I want to make it so that typing "vi foo" at the shell prompt (as in
M-x shell) does like C-x C-f foo RET. Thus, I wrote
shell-integration.el (posted to gnu.emacs.sources).
The mode looks whether it knows the command typed as the first word on
the line and then invokes a lisp function, if so. I thought it would
be good if that lisp function received a list of arguments.
That's why I wanted to split the current command line into words.
Now I have used the following workaround: each such lisp function
receives only a single string as its arg, which is the whole command
line. The lisp functions then (normally) use the comint-arguments
function to extract the words they need.
Hm. It seems that my approach was too simple-minded, as I can't say
"vi $(uname)" -- this will try to edit a file called "$(uname)" rather
than editing a file called "Linux". So I guess I need to pass the
command to the shell for expansion first, then pass the result to the
Lisp function.
Kai