* About "program" and "command"
@ 2013-03-24 12:32 Xue Fuqiao
2013-03-24 13:42 ` Andreas Röhler
2013-03-24 14:30 ` Yuri Khan
0 siblings, 2 replies; 5+ messages in thread
From: Xue Fuqiao @ 2013-03-24 12:32 UTC (permalink / raw)
To: help-gnu-emacs
The doc string of `call-process' says:
Call PROGRAM synchronously in separate process.
The doc string of `call-process-shell-command' says:
Execute the shell command COMMAND synchronously in separate process.
What's the different of these two functions? In other words, what's the
difference of "program" and "command" here? After searching the
archives, I found two threads[1][2], but they don't help. So can I get
a pointer to information on these two concepts?
[1] http://lists.gnu.org/archive/html/help-gnu-emacs/2010-09/msg00009.html
[2] http://lists.gnu.org/archive/html/help-gnu-emacs/2007-10/msg00059.html
--
Xue Fuqiao
http://www.gnu.org/software/emacs/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: About "program" and "command"
2013-03-24 12:32 About "program" and "command" Xue Fuqiao
@ 2013-03-24 13:42 ` Andreas Röhler
2013-03-24 14:30 ` Yuri Khan
1 sibling, 0 replies; 5+ messages in thread
From: Andreas Röhler @ 2013-03-24 13:42 UTC (permalink / raw)
To: help-gnu-emacs
Am 24.03.2013 13:32, schrieb Xue Fuqiao:
> The doc string of `call-process' says:
>
> Call PROGRAM synchronously in separate process.
>
> The doc string of `call-process-shell-command' says:
>
> Execute the shell command COMMAND synchronously in separate process.
>
> What's the different of these two functions? In other words, what's the
> difference of "program" and "command" here? After searching the
> archives, I found two threads[1][2], but they don't help. So can I get
> a pointer to information on these two concepts?
>
>
> [1] http://lists.gnu.org/archive/html/help-gnu-emacs/2010-09/msg00009.html
> [2] http://lists.gnu.org/archive/html/help-gnu-emacs/2007-10/msg00059.html
>
Hi,
the commander, that's you. I.e. a command is a function designed for interactive use.
While a program is every recipe directed at computer, wherefrom wherever.
Probably most commanders here also are programmers :)
Andreas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: About "program" and "command"
2013-03-24 12:32 About "program" and "command" Xue Fuqiao
2013-03-24 13:42 ` Andreas Röhler
@ 2013-03-24 14:30 ` Yuri Khan
1 sibling, 0 replies; 5+ messages in thread
From: Yuri Khan @ 2013-03-24 14:30 UTC (permalink / raw)
To: Xue Fuqiao; +Cc: help-gnu-emacs
On Sun, Mar 24, 2013 at 7:32 PM, Xue Fuqiao <xfq.free@gmail.com> wrote:
> The doc string of `call-process' says:
>
> Call PROGRAM synchronously in separate process.
>
> The doc string of `call-process-shell-command' says:
>
> Execute the shell command COMMAND synchronously in separate process.
>
> What's the different of these two functions? In other words, what's the
> difference of "program" and "command" here?
I would expect that “program” refers to only the binary being invoked,
without its command-line arguments; while “command” refers to the
whole command including the binary and the arguments, and, with the
explicit qualification as a “shell command”, probably also with such
shell-specific constructs as environment variables, input/output
redirection, piping, etc.
Of course, my expectations could be completely wrong.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: About "program" and "command"
[not found] <mailman.22746.1364128338.855.help-gnu-emacs@gnu.org>
@ 2013-03-24 14:34 ` Barry Margolin
2013-03-24 14:34 ` Pascal J. Bourguignon
1 sibling, 0 replies; 5+ messages in thread
From: Barry Margolin @ 2013-03-24 14:34 UTC (permalink / raw)
To: help-gnu-emacs
In article <mailman.22746.1364128338.855.help-gnu-emacs@gnu.org>,
Xue Fuqiao <xfq.free@gmail.com> wrote:
> The doc string of `call-process' says:
>
> Call PROGRAM synchronously in separate process.
>
> The doc string of `call-process-shell-command' says:
>
> Execute the shell command COMMAND synchronously in separate process.
>
> What's the different of these two functions? In other words, what's the
> difference of "program" and "command" here? After searching the
> archives, I found two threads[1][2], but they don't help. So can I get
> a pointer to information on these two concepts?
>
>
> [1] http://lists.gnu.org/archive/html/help-gnu-emacs/2010-09/msg00009.html
> [2] http://lists.gnu.org/archive/html/help-gnu-emacs/2007-10/msg00059.html
A program is just a single external executable. A shell command is a
whole shell command line -- it can run multiple commands (separated by
';') and use shell metacharacters (wildcard filenames, backticks, I/O
redirection and piping, etc.).
It's like the difference between execl() and system() in C programming.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: About "program" and "command"
[not found] <mailman.22746.1364128338.855.help-gnu-emacs@gnu.org>
2013-03-24 14:34 ` Barry Margolin
@ 2013-03-24 14:34 ` Pascal J. Bourguignon
1 sibling, 0 replies; 5+ messages in thread
From: Pascal J. Bourguignon @ 2013-03-24 14:34 UTC (permalink / raw)
To: help-gnu-emacs
Xue Fuqiao <xfq.free@gmail.com> writes:
> The doc string of `call-process' says:
>
> Call PROGRAM synchronously in separate process.
>
> The doc string of `call-process-shell-command' says:
>
> Execute the shell command COMMAND synchronously in separate process.
>
> What's the different of these two functions? In other words, what's the
> difference of "program" and "command" here? After searching the
> archives, I found two threads[1][2], but they don't help. So can I get
> a pointer to information on these two concepts?
Some shell commands are not programs, but built-in routines in the
shell. Or also, aliases, functions, etc.
Compare:
(let ((buffer (get-buffer-create (generate-new-buffer-name "*test*"))))
(call-process-shell-command "set" nil buffer)
(switch-to-buffer buffer))
with:
(let ((buffer (get-buffer-create (generate-new-buffer-name "*test*"))))
(call-process "set" nil buffer)
(switch-to-buffer buffer))
In some cases, there are both a command and a program so this may be
confusing. For example, there is /bin/echo and the builtin echo. They
may behave differently!
Again, compare:
(let ((buffer (get-buffer-create (generate-new-buffer-name "*test*"))))
(call-process-shell-command "echo" nil buffer nil "--help")
(switch-to-buffer buffer))
with:
(let ((buffer (get-buffer-create (generate-new-buffer-name "*test*"))))
(call-process "echo" nil buffer nil "--help")
(switch-to-buffer buffer))
Bash has a builtin named 'command' that skip looking for functions or
aliases, but still runs the built-in command if there's one.
Bash also has a builtin named 'enable' which lets you enable or disable
a builtin command, so it doesn't shadow the programs.
Also since call-process-shell-command uses the shell to interpret the
'command', one can pass several commands separated with semicolon:
(let ((buffer (get-buffer-create (generate-new-buffer-name "*test*"))))
(call-process-shell-command "echo a ; echo b" nil buffer)
(switch-to-buffer buffer))
(let ((buffer (get-buffer-create (generate-new-buffer-name "*test*"))))
(call-process-shell-command "echo --help ; enable -n echo ; echo --help" nil buffer)
(switch-to-buffer buffer))
or of course, you can always give the path to the program to avoid the
builtin command:
(let ((buffer (get-buffer-create (generate-new-buffer-name "*test*"))))
(call-process-shell-command "echo --help ; /bin/echo --help" nil buffer)
(switch-to-buffer buffer))
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-03-24 14:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-24 12:32 About "program" and "command" Xue Fuqiao
2013-03-24 13:42 ` Andreas Röhler
2013-03-24 14:30 ` Yuri Khan
[not found] <mailman.22746.1364128338.855.help-gnu-emacs@gnu.org>
2013-03-24 14:34 ` Barry Margolin
2013-03-24 14:34 ` Pascal J. Bourguignon
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.