aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc/eshell.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/misc/eshell.texi')
-rw-r--r--doc/misc/eshell.texi82
1 files changed, 57 insertions, 25 deletions
diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index 9f9c88582f3..13f13163dd7 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -201,7 +201,7 @@ history and invoking commands in a script file.
201* Aliases:: 201* Aliases::
202* History:: 202* History::
203* Completion:: 203* Completion::
204* for loop:: 204* Control Flow::
205* Scripts:: 205* Scripts::
206@end menu 206@end menu
207 207
@@ -219,12 +219,18 @@ same name; if there is no match, it then tries to execute it as an
219external command. 219external command.
220 220
221The semicolon (@code{;}) can be used to separate multiple command 221The semicolon (@code{;}) can be used to separate multiple command
222invocations on a single line. A command invocation followed by an 222invocations on a single line. You can also separate commands with
223ampersand (@code{&}) will be run in the background. Eshell has no job 223@code{&&} or @code{||}. When using @code{&&}, Eshell will execute the
224control, so you can not suspend or background the current process, or 224second command only if the first succeeds (i.e.@: has an exit
225bring a background process into the foreground. That said, background 225status of 0); with @code{||}, Eshell will execute the second command
226processes invoked from Eshell can be controlled the same way as any 226only if the first fails.
227other background process in Emacs. 227
228A command invocation followed by an ampersand (@code{&}) will be run
229in the background. Eshell has no job control, so you can not suspend
230or background the current process, or bring a background process into
231the foreground. That said, background processes invoked from Eshell
232can be controlled the same way as any other background process in
233Emacs.
228 234
229@node Arguments 235@node Arguments
230@section Arguments 236@section Arguments
@@ -884,14 +890,18 @@ command (excluding the command name itself).
884 890
885@vindex $$ 891@vindex $$
886@item $$ 892@item $$
887This is the result of the last command. In case of an external 893This is the result of the last command. For external commands, it is
888command, it is @code{t} or @code{nil}. 894@code{t} if the exit code was 0 or @code{nil} otherwise.
889 895
896@vindex eshell-lisp-form-nil-is-failure
890@vindex $? 897@vindex $?
891@item $? 898@item $?
892This variable contains the exit code of the last command. If the last 899This variable contains the exit code of the last command. If the last
893command was a Lisp function, it is 0 for successful completion or 1 900command was a Lisp function, it is 0 for successful completion or 1
894otherwise. 901otherwise. If @code{eshell-lisp-form-nil-is-failure} is
902non-@code{nil}, then a command with a Lisp form, like
903@samp{(@var{command} @var{args}@dots{})}, that returns @code{nil} will
904set this variable to 2.
895 905
896@vindex $COLUMNS 906@vindex $COLUMNS
897@vindex $LINES 907@vindex $LINES
@@ -1008,19 +1018,46 @@ command for which this function provides completions; you can also name
1008the function @code{pcomplete/MAJOR-MODE/COMMAND} to define completions 1018the function @code{pcomplete/MAJOR-MODE/COMMAND} to define completions
1009for a specific major mode. 1019for a specific major mode.
1010 1020
1011@node for loop 1021@node Control Flow
1012@section @code{for} loop 1022@section Control Flow
1013Because Eshell commands can not (easily) be combined with lisp forms, 1023Because Eshell commands can not (easily) be combined with lisp forms,
1014Eshell provides a command-oriented @command{for}-loop for convenience. 1024Eshell provides command-oriented control flow statements for
1015The syntax is as follows: 1025convenience.
1016 1026
1017@example 1027Most of Eshell's control flow statements accept a @var{conditional}.
1018@code{for VAR in TOKENS @{ command invocation(s) @}} 1028This can take a few different forms. If @var{conditional} is a dollar
1019@end example 1029expansion, the condition is satisfied if the result is a
1030non-@code{nil} value. If @var{conditional} is a @samp{@{
1031@var{subcommand} @}} or @samp{(@var{lisp form})}, the condition is
1032satisfied if the command's exit status is 0.
1033
1034@table @code
1035
1036@item if @var{conditional} @{ @var{true-commands} @}
1037@itemx if @var{conditional} @{ @var{true-commands} @} @{ @var{false-commands} @}
1038Evaluate @var{true-commands} if @var{conditional} is satisfied;
1039otherwise, evaluate @var{false-commands}.
1040
1041@item unless @var{conditional} @{ @var{false-commands} @}
1042@itemx unless @var{conditional} @{ @var{false-commands} @} @{ @var{true-commands} @}
1043Evaluate @var{false-commands} if @var{conditional} is not satisfied;
1044otherwise, evaluate @var{true-commands}.
1020 1045
1021where @samp{TOKENS} is a space-separated sequence of values of 1046@item while @var{conditional} @{ @var{commands} @}
1022@var{VAR} for each iteration. This can even be the output of a 1047Repeatedly evaluate @var{commands} so long as @var{conditional} is
1023command if @samp{TOKENS} is replaced with @samp{@{ command invocation @}}. 1048satisfied.
1049
1050@item until @var{conditional} @{ @var{commands} @}
1051Repeatedly evaluate @var{commands} until @var{conditional} is
1052satisfied.
1053
1054@item for @var{var} in @var{list}@dots{} @{ @var{commands} @}
1055Iterate over each element of of @var{list}, storing the element in
1056@var{var} and evaluating @var{commands}. If @var{list} is not a list,
1057treat it as a list of one element. If you specify multiple
1058@var{lists}, this will iterate over each of them in turn.
1059
1060@end table
1024 1061
1025@node Scripts 1062@node Scripts
1026@section Scripts 1063@section Scripts
@@ -1811,11 +1848,6 @@ scrolls back.
1811 1848
1812@item Menu support was removed, but never put back 1849@item Menu support was removed, but never put back
1813 1850
1814@item Using C-p and C-n with rebind gets into a locked state
1815
1816This happened a few times in Emacs 21, but has been irreproducible
1817since.
1818
1819@item If an interactive process is currently running, @kbd{M-!} doesn't work 1851@item If an interactive process is currently running, @kbd{M-!} doesn't work
1820 1852
1821@item Use a timer instead of @code{sleep-for} when killing child processes 1853@item Use a timer instead of @code{sleep-for} when killing child processes