mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-14 07:30:49 +02:00
commit bash-20130823 snapshot
This commit is contained in:
@@ -5174,3 +5174,46 @@ builtins/fc.def
|
||||
use it if -0 is specified as the beginning or end of the history
|
||||
range to list. Doesn't work for fc -e or fc -s by design. Feature
|
||||
requested by Mike Fied <micfied@gmail.com>
|
||||
|
||||
8/16
|
||||
----
|
||||
trap.c
|
||||
- _run_trap_internal: use {save,restore}_parser_state instead of
|
||||
{save,restore}_token_state. It's more comprehensive
|
||||
|
||||
8/23
|
||||
----
|
||||
doc/bash.1
|
||||
- disown: remove repeated text. Report and fix from Thomas Hood
|
||||
<jdthood@gmail.com>
|
||||
|
||||
8/25
|
||||
----
|
||||
lib/readline/rltty.c
|
||||
- set_special_char: fix prototype (last arg is rl_command_func_t *)
|
||||
|
||||
sig.c
|
||||
- set_signal_handler: return oact.sa_handler only if sigaction
|
||||
succeeds; if it doesn't, return SIG_DFL (reasonable default). From
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=911404
|
||||
|
||||
bashline.c
|
||||
- attempt_shell_completion: fix to skip assignment statements preceding
|
||||
command name even if there are no programmable completions defined.
|
||||
From https://bugzilla.redhat.com/show_bug.cgi?id=994659
|
||||
- attempt_shell_completion: if still completing command word following
|
||||
assignment statements, do command completion even if programmable
|
||||
completion defined for partial command name entered so far
|
||||
|
||||
8/26
|
||||
----
|
||||
pcomplete.c
|
||||
- pcomp_filename_completion_function: make sure rl_filename_dequoting_function
|
||||
is non-NULL before trying to call it. Bug and fix from
|
||||
Andreas Schwab <schwab@linux-m68k.org>
|
||||
|
||||
bashline.c
|
||||
- bash_command_name_stat_hook: if *name is not something we're going
|
||||
to look up in $PATH (absolute_program(*name) != 0), just call the
|
||||
usual bash_filename_stat_hook and return those results. This makes
|
||||
completions like $PWD/exam[TAB] add a trailing slash
|
||||
|
||||
+81
-1
@@ -5130,4 +5130,84 @@ arrayfunc.c
|
||||
- assign_array_element_internal: before using array_max_index() when
|
||||
processing a negative subscript, make sure the variable is an array.
|
||||
if it's not, use 0 as array_max_index assuming it's a string.
|
||||
Bug report from Geir Hauge <geir.hauge@gmail.com>
|
||||
Fixes bug report from Geir Hauge <geir.hauge@gmail.com>
|
||||
|
||||
8/3
|
||||
---
|
||||
Makefile.in
|
||||
- pcomplete.o: add dependency on $(DEFDIR)/builtext.h. Suggested by
|
||||
Curtis Doty <curtis@greenkey.net>
|
||||
|
||||
8/5
|
||||
---
|
||||
lib/glob/sm_loop.c
|
||||
- strcompare: short-circuit and return FNM_NOMATCH if the lengths of the
|
||||
pattern and string (pe - p and se - s, respectively) are not equal
|
||||
- strcompare: don't bother trying to set *pe or *se to '\0' if that's
|
||||
what they already are. Fixes bug reported by Geir Hauge
|
||||
<geir.hauge@gmail.com>
|
||||
|
||||
8/6
|
||||
---
|
||||
doc/{bash.1,bashref.texi},builtins/hash.def,lib/readline/doc/rluser.texi
|
||||
- minor typo changes from Geir Hauge <geir.hauge@gmail.com>
|
||||
|
||||
bultins/help.def
|
||||
- show_longdoc: avoid trying to translate the empty string because it
|
||||
often translates to some boilerplate about the project and
|
||||
translation. Report and fix from Geir Hauge <geir.hauge@gmail.com>
|
||||
|
||||
8/8
|
||||
---
|
||||
builtins/help.def
|
||||
- help_builtin: try two passes through the list of help topics for each
|
||||
argument: one doing exact string matching and one, if the first pass
|
||||
fails to find a match, doing string prefix matching like previous
|
||||
versions. This prevents `help read' from matching both `read' and
|
||||
`readonly', but allows `help r' to match everything beginning with
|
||||
`r'. Inspired by report from Geir Hauge <geir.hauge@gmail.com>
|
||||
|
||||
8/13
|
||||
----
|
||||
builtins/fc.def
|
||||
- fc_builtin,fc_gethnum: calculate `real' end of the history list and
|
||||
use it if -0 is specified as the beginning or end of the history
|
||||
range to list. Doesn't work for fc -e or fc -s by design. Feature
|
||||
requested by Mike Fied <micfied@gmail.com>
|
||||
|
||||
8/16
|
||||
----
|
||||
trap.c
|
||||
- _run_trap_internal: use {save,restore}_parser_state instead of
|
||||
{save,restore}_token_state. It's more comprehensive
|
||||
|
||||
8/23
|
||||
----
|
||||
doc/bash.1
|
||||
- disown: remove repeated text. Report and fix from Thomas Hood
|
||||
<jdthood@gmail.com>
|
||||
|
||||
8/25
|
||||
----
|
||||
lib/readline/rltty.c
|
||||
- set_special_char: fix prototype (last arg is rl_command_func_t *)
|
||||
|
||||
sig.c
|
||||
- set_signal_handler: return oact.sa_handler only if sigaction
|
||||
succeeds; if it doesn't, return SIG_DFL (reasonable default). From
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=911404
|
||||
|
||||
bashline.c
|
||||
- attempt_shell_completion: fix to skip assignment statements preceding
|
||||
command name even if there are no programmable completions defined.
|
||||
From https://bugzilla.redhat.com/show_bug.cgi?id=994659
|
||||
- attempt_shell_completion: if still completing command word following
|
||||
assignment statements, do command completion even if programmable
|
||||
completion defined for partial command name entered so far
|
||||
|
||||
8/26
|
||||
----
|
||||
pcomplete.c
|
||||
- pcomp_filename_completion_function: make sure rl_filename_dequoting_function
|
||||
is non-NULL before trying to call it. Bug and fix from
|
||||
Andreas Schwab <schwab@linux-m68k.org>
|
||||
|
||||
+33
-6
@@ -1374,6 +1374,9 @@ attempt_shell_completion (text, start, end)
|
||||
{
|
||||
int in_command_position, ti, saveti, qc, dflags;
|
||||
char **matches, *command_separator_chars;
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
int have_progcomps, was_assignment;
|
||||
#endif
|
||||
|
||||
command_separator_chars = COMMAND_SEPARATORS;
|
||||
matches = (char **)NULL;
|
||||
@@ -1448,8 +1451,8 @@ attempt_shell_completion (text, start, end)
|
||||
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
/* Attempt programmable completion. */
|
||||
have_progcomps = prog_completion_enabled && (progcomp_size () > 0);
|
||||
if (matches == 0 && (in_command_position == 0 || text[0] == '\0') &&
|
||||
prog_completion_enabled && (progcomp_size () > 0) &&
|
||||
current_prompt_string == ps1_prompt)
|
||||
{
|
||||
int s, e, s1, e1, os, foundcs;
|
||||
@@ -1474,23 +1477,42 @@ attempt_shell_completion (text, start, end)
|
||||
n = find_cmd_name (s, &s1, &e1);
|
||||
s = e1 + 1;
|
||||
}
|
||||
while (assignment (n, 0));
|
||||
while (was_assignment = assignment (n, 0));
|
||||
s = s1; /* reset to index where name begins */
|
||||
|
||||
/* s == index of where command name begins (reset above)
|
||||
e == end of current command, may be end of line
|
||||
s1 = index of where command name begins
|
||||
e1 == index of where command name ends
|
||||
start == index of where word to be completed begins
|
||||
end == index of where word to be completed ends
|
||||
if (s == start) we are doing command word completion for sure
|
||||
if (e1 == end) we are at the end of the command name and completing it */
|
||||
if (start == 0 && end == 0 && e != 0 && text[0] == '\0') /* beginning of non-empty line */
|
||||
foundcs = 0;
|
||||
else if (start == end && start == s1 && e != 0 && e1 > end) /* beginning of command name, leading whitespace */
|
||||
foundcs = 0;
|
||||
else if (e == 0 && e == s && text[0] == '\0') /* beginning of empty line */
|
||||
else if (e == 0 && e == s && text[0] == '\0' && have_progcomps) /* beginning of empty line */
|
||||
prog_complete_matches = programmable_completions ("_EmptycmD_", text, s, e, &foundcs);
|
||||
else if (start == end && text[0] == '\0' && s1 > start && whitespace (rl_line_buffer[start]))
|
||||
foundcs = 0; /* whitespace before command name */
|
||||
else if (e > s && assignment (n, 0) == 0)
|
||||
prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
|
||||
else if (e > s && was_assignment == 0 && e1 == end && rl_line_buffer[e] == 0 && whitespace (rl_line_buffer[e-1]) == 0)
|
||||
{
|
||||
/* not assignment statement, but still want to perform command
|
||||
completion if we are composing command word. */
|
||||
foundcs = 0;
|
||||
in_command_position = s == start && STREQ (n, text); /* XXX */
|
||||
}
|
||||
else if (e > s && was_assignment == 0 && have_progcomps)
|
||||
{
|
||||
prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
|
||||
/* command completion if programmable completion fails */
|
||||
in_command_position = s == start && STREQ (n, text); /* XXX */
|
||||
}
|
||||
else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0)
|
||||
{
|
||||
foundcs = 0; /* empty command name following assignments */
|
||||
in_command_position = 1;
|
||||
in_command_position = was_assignment;
|
||||
}
|
||||
else if (s == start && e == end && STREQ (n, text) && start > 0)
|
||||
{
|
||||
@@ -1650,6 +1672,11 @@ bash_command_name_stat_hook (name)
|
||||
{
|
||||
char *cname, *result;
|
||||
|
||||
/* If it's not something we're going to look up in $PATH, just call the
|
||||
normal filename stat hook. */
|
||||
if (absolute_program (*name))
|
||||
return (bash_filename_stat_hook (name));
|
||||
|
||||
cname = *name;
|
||||
/* XXX - we could do something here with converting aliases, builtins,
|
||||
and functions into something that came out as executable, but we don't. */
|
||||
|
||||
+4156
File diff suppressed because it is too large
Load Diff
+4181
File diff suppressed because it is too large
Load Diff
+2
-9
@@ -7569,8 +7569,8 @@ Without options, remove each
|
||||
from the table of active jobs.
|
||||
If
|
||||
.I jobspec
|
||||
is not present, and neither \fB\-a\fP nor \fB\-r\fP is supplied,
|
||||
the shell's notion of the \fIcurrent job\fP is used.
|
||||
is not present, and neither the \fB\-a\fP nor the \fB\-r\fP option
|
||||
is supplied, the \fIcurrent job\fP is used.
|
||||
If the \fB\-h\fP option is given, each
|
||||
.I jobspec
|
||||
is not removed from the table, but is marked so that
|
||||
@@ -7581,13 +7581,6 @@ is not sent to the job if the shell receives a
|
||||
.BR SIGHUP .
|
||||
If no
|
||||
.I jobspec
|
||||
is present, and neither the
|
||||
.B \-a
|
||||
nor the
|
||||
.B \-r
|
||||
option is supplied, the \fIcurrent job\fP is used.
|
||||
If no
|
||||
.I jobspec
|
||||
is supplied, the
|
||||
.B \-a
|
||||
option means to remove or mark all jobs; the
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@
|
||||
\entry{caller}{48}{\code {caller}}
|
||||
\entry{command}{49}{\code {command}}
|
||||
\entry{declare}{49}{\code {declare}}
|
||||
\entry{echo}{50}{\code {echo}}
|
||||
\entry{echo}{51}{\code {echo}}
|
||||
\entry{enable}{51}{\code {enable}}
|
||||
\entry{help}{52}{\code {help}}
|
||||
\entry{let}{52}{\code {let}}
|
||||
@@ -44,7 +44,7 @@
|
||||
\entry{shopt}{61}{\code {shopt}}
|
||||
\entry{dirs}{90}{\code {dirs}}
|
||||
\entry{popd}{90}{\code {popd}}
|
||||
\entry{pushd}{90}{\code {pushd}}
|
||||
\entry{pushd}{91}{\code {pushd}}
|
||||
\entry{bg}{98}{\code {bg}}
|
||||
\entry{fg}{98}{\code {fg}}
|
||||
\entry{jobs}{98}{\code {jobs}}
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@
|
||||
\entry {\code {dirs}}{90}
|
||||
\entry {\code {disown}}{99}
|
||||
\initial {E}
|
||||
\entry {\code {echo}}{50}
|
||||
\entry {\code {echo}}{51}
|
||||
\entry {\code {enable}}{51}
|
||||
\entry {\code {eval}}{41}
|
||||
\entry {\code {exec}}{41}
|
||||
@@ -52,7 +52,7 @@
|
||||
\initial {P}
|
||||
\entry {\code {popd}}{90}
|
||||
\entry {\code {printf}}{53}
|
||||
\entry {\code {pushd}}{90}
|
||||
\entry {\code {pushd}}{91}
|
||||
\entry {\code {pwd}}{43}
|
||||
\initial {R}
|
||||
\entry {\code {read}}{54}
|
||||
|
||||
Binary file not shown.
+14
-26
@@ -1,4 +1,4 @@
|
||||
This is TeX, Version 3.1415926 (TeX Live 2011/Fink) (format=tex 2012.4.18) 8 MAR 2013 15:57
|
||||
This is TeX, Version 3.1415926 (TeX Live 2011/Fink) (format=tex 2012.4.18) 19 AUG 2013 15:43
|
||||
**/usr/homes/chet/src/bash/src/doc/bashref.texi
|
||||
(/usr/homes/chet/src/bash/src/doc/bashref.texi (./texinfo.tex
|
||||
Loading texinfo [version 2009-01-18.17]:
|
||||
@@ -232,7 +232,7 @@ arallel -k traceroute[]
|
||||
[16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30]
|
||||
[31] [32] [33] [34] [35] [36] [37] [38] Chapter 4 [39] [40] [41] [42] [43]
|
||||
[44] [45] [46]
|
||||
Underfull \hbox (badness 5231) in paragraph at lines 3760--3773
|
||||
Underfull \hbox (badness 5231) in paragraph at lines 3762--3775
|
||||
@texttt emacs-meta[]@textrm , @texttt emacs-ctlx[]@textrm , @texttt vi[]@textr
|
||||
m , @texttt vi-move[]@textrm , @texttt vi-command[]@textrm , and
|
||||
|
||||
@@ -245,21 +245,9 @@ m , @texttt vi-move[]@textrm , @texttt vi-command[]@textrm , and
|
||||
.etc.
|
||||
|
||||
[47] [48] [49] [50] [51] [52] [53] [54] [55] [56] [57] [58] [59] [60] [61]
|
||||
[62] [63] [64]
|
||||
Underfull \hbox (badness 5460) in paragraph at lines 5047--5053
|
||||
[]@textrm If set, range ex-pres-sions used in pat-tern match-ing (see
|
||||
|
||||
@hbox(8.2125+2.73749)x433.62, glue set 3.79674
|
||||
.@glue(@leftskip) 115.63242
|
||||
.@hbox(0.0+0.0)x0.0
|
||||
.@textrm I
|
||||
.@textrm f
|
||||
.@glue 3.65 plus 1.825 minus 1.21666
|
||||
.etc.
|
||||
|
||||
[65] [66] Chapter 5 [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77]
|
||||
Chapter 6 [78]
|
||||
Overfull \hbox (51.96864pt too wide) in paragraph at lines 5972--5972
|
||||
[62] [63] [64] [65] [66] Chapter 5 [67] [68] [69] [70] [71] [72] [73] [74]
|
||||
[75] [76] [77] Chapter 6 [78]
|
||||
Overfull \hbox (51.96864pt too wide) in paragraph at lines 5979--5979
|
||||
[]@texttt bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@t
|
||||
exttt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
|
||||
|
||||
@@ -272,7 +260,7 @@ exttt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
|
||||
.etc.
|
||||
|
||||
|
||||
Overfull \hbox (76.23077pt too wide) in paragraph at lines 5973--5973
|
||||
Overfull \hbox (76.23077pt too wide) in paragraph at lines 5980--5980
|
||||
[]@texttt bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@texttt
|
||||
] [-O @textttsl shopt_option@texttt ] -c @textttsl string @texttt [@textttsl ar
|
||||
-
|
||||
@@ -286,7 +274,7 @@ Overfull \hbox (76.23077pt too wide) in paragraph at lines 5973--5973
|
||||
.etc.
|
||||
|
||||
|
||||
Overfull \hbox (34.72258pt too wide) in paragraph at lines 5974--5974
|
||||
Overfull \hbox (34.72258pt too wide) in paragraph at lines 5981--5981
|
||||
[]@texttt bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@text
|
||||
tt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
|
||||
|
||||
@@ -299,7 +287,7 @@ tt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
|
||||
.etc.
|
||||
|
||||
[79] [80]
|
||||
Underfull \hbox (badness 2245) in paragraph at lines 6146--6148
|
||||
Underfull \hbox (badness 2245) in paragraph at lines 6153--6155
|
||||
[]@textrm When a lo-gin shell ex-its, Bash reads and ex-e-cutes com-mands from
|
||||
the file
|
||||
|
||||
@@ -311,8 +299,8 @@ the file
|
||||
.@textrm n
|
||||
.etc.
|
||||
|
||||
[81] [82] [83] [84] [85] [86] [87] [88] [89] [90] [91] [92] [93] [94]
|
||||
Underfull \hbox (badness 2521) in paragraph at lines 7358--7361
|
||||
[81] [82] [83] [84] [85] [86] [87] [88] [89] [90] [91] [92] [93] [94] [95]
|
||||
Underfull \hbox (badness 2521) in paragraph at lines 7371--7374
|
||||
@textrm `@texttt --enable-strict-posix-default[]@textrm '[] to @texttt configur
|
||||
e[] @textrm when build-ing (see Sec-tion 10.8
|
||||
|
||||
@@ -324,7 +312,7 @@ e[] @textrm when build-ing (see Sec-tion 10.8
|
||||
.@texttt n
|
||||
.etc.
|
||||
|
||||
Chapter 7 [95] [96] [97] [98] [99]
|
||||
Chapter 7 [96] [97] [98] [99]
|
||||
(/usr/homes/chet/src/bash/src/lib/readline/doc/rluser.texi Chapter 8 [100]
|
||||
[101] [102] [103] [104] [105] [106]
|
||||
Underfull \hbox (badness 5231) in paragraph at lines 565--581
|
||||
@@ -393,7 +381,7 @@ athname[]
|
||||
|
||||
[131]) (/usr/homes/chet/src/bash/src/lib/readline/doc/hsuser.texi Chapter 9
|
||||
[132] [133] [134] [135] [136]) Chapter 10 [137] [138] [139] [140]
|
||||
Underfull \hbox (badness 2772) in paragraph at lines 7966--7970
|
||||
Underfull \hbox (badness 2772) in paragraph at lines 7979--7983
|
||||
[]@textrm Enable sup-port for large files (@texttt http://www.sas.com/standard
|
||||
s/large_
|
||||
|
||||
@@ -412,10 +400,10 @@ Appendix D [159] (./bashref.bts) [160] (./bashref.rws) (./bashref.vrs [161]
|
||||
Here is how much of TeX's memory you used:
|
||||
2085 strings out of 497974
|
||||
28645 string characters out of 3220833
|
||||
66392 words of memory out of 3000000
|
||||
66401 words of memory out of 3000000
|
||||
2901 multiletter control sequences out of 15000+200000
|
||||
32127 words of font info for 112 fonts, out of 3000000 for 9000
|
||||
51 hyphenation exceptions out of 8191
|
||||
16i,6n,14p,319b,705s stack positions out of 5000i,500n,10000p,200000b,50000s
|
||||
|
||||
Output written on bashref.dvi (172 pages, 717824 bytes).
|
||||
Output written on bashref.dvi (172 pages, 719444 bytes).
|
||||
|
||||
Binary file not shown.
+2
-2
@@ -7611,8 +7611,8 @@ active jobs.
|
||||
If the @option{-h} option is given, the job is not removed from the table,
|
||||
but is marked so that @code{SIGHUP} is not sent to the job if the shell
|
||||
receives a @code{SIGHUP}.
|
||||
If @var{jobspec} is not present, and neither the @option{-a} nor @option{-r}
|
||||
option is supplied, the current job is used.
|
||||
If @var{jobspec} is not present, and neither the @option{-a} nor the
|
||||
@option{-r} option is supplied, the current job is used.
|
||||
If no @var{jobspec} is supplied, the @option{-a} option means to remove or
|
||||
mark all jobs; the @option{-r} option without a @var{jobspec}
|
||||
argument restricts operation to running jobs.
|
||||
|
||||
@@ -121,7 +121,7 @@ static int set_tty_settings PARAMS((int, TIOTYPE *));
|
||||
|
||||
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
|
||||
|
||||
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
|
||||
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t *));
|
||||
|
||||
static void
|
||||
save_tty_chars (tiop)
|
||||
@@ -341,7 +341,7 @@ static int set_tty_settings PARAMS((int, TIOTYPE *));
|
||||
|
||||
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
|
||||
|
||||
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
|
||||
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t *));
|
||||
static void _rl_bind_tty_special_chars PARAMS((Keymap, TIOTYPE));
|
||||
|
||||
#if defined (FLUSHO)
|
||||
|
||||
@@ -0,0 +1,975 @@
|
||||
/* rltty.c -- functions to prepare and restore the terminal for readline's
|
||||
use. */
|
||||
|
||||
/* Copyright (C) 1992-2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#include "rldefs.h"
|
||||
|
||||
#if defined (GWINSZ_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* GWINSZ_IN_SYS_IOCTL */
|
||||
|
||||
#include "rltty.h"
|
||||
#include "readline.h"
|
||||
#include "rlprivate.h"
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
|
||||
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
|
||||
|
||||
static void set_winsize PARAMS((int));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Saving and Restoring the TTY */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Non-zero means that the terminal is in a prepped state. */
|
||||
static int terminal_prepped;
|
||||
|
||||
static _RL_TTY_CHARS _rl_tty_chars, _rl_last_tty_chars;
|
||||
|
||||
/* If non-zero, means that this process has called tcflow(fd, TCOOFF)
|
||||
and output is suspended. */
|
||||
#if defined (__ksr1__)
|
||||
static int ksrflow;
|
||||
#endif
|
||||
|
||||
/* Dummy call to force a backgrounded readline to stop before it tries
|
||||
to get the tty settings. */
|
||||
static void
|
||||
set_winsize (tty)
|
||||
int tty;
|
||||
{
|
||||
#if defined (TIOCGWINSZ)
|
||||
struct winsize w;
|
||||
|
||||
if (ioctl (tty, TIOCGWINSZ, &w) == 0)
|
||||
(void) ioctl (tty, TIOCSWINSZ, &w);
|
||||
#endif /* TIOCGWINSZ */
|
||||
}
|
||||
|
||||
#if defined (NO_TTY_DRIVER)
|
||||
/* Nothing */
|
||||
#elif defined (NEW_TTY_DRIVER)
|
||||
|
||||
/* Values for the `flags' field of a struct bsdtty. This tells which
|
||||
elements of the struct bsdtty have been fetched from the system and
|
||||
are valid. */
|
||||
#define SGTTY_SET 0x01
|
||||
#define LFLAG_SET 0x02
|
||||
#define TCHARS_SET 0x04
|
||||
#define LTCHARS_SET 0x08
|
||||
|
||||
struct bsdtty {
|
||||
struct sgttyb sgttyb; /* Basic BSD tty driver information. */
|
||||
int lflag; /* Local mode flags, like LPASS8. */
|
||||
#if defined (TIOCGETC)
|
||||
struct tchars tchars; /* Terminal special characters, including ^S and ^Q. */
|
||||
#endif
|
||||
#if defined (TIOCGLTC)
|
||||
struct ltchars ltchars; /* 4.2 BSD editing characters */
|
||||
#endif
|
||||
int flags; /* Bitmap saying which parts of the struct are valid. */
|
||||
};
|
||||
|
||||
#define TIOTYPE struct bsdtty
|
||||
|
||||
static TIOTYPE otio;
|
||||
|
||||
static void save_tty_chars PARAMS((TIOTYPE *));
|
||||
static int _get_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int get_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int _set_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int set_tty_settings PARAMS((int, TIOTYPE *));
|
||||
|
||||
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
|
||||
|
||||
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
|
||||
|
||||
static void
|
||||
save_tty_chars (tiop)
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
_rl_last_tty_chars = _rl_tty_chars;
|
||||
|
||||
if (tiop->flags & SGTTY_SET)
|
||||
{
|
||||
_rl_tty_chars.t_erase = tiop->sgttyb.sg_erase;
|
||||
_rl_tty_chars.t_kill = tiop->sgttyb.sg_kill;
|
||||
}
|
||||
|
||||
if (tiop->flags & TCHARS_SET)
|
||||
{
|
||||
_rl_intr_char = _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
|
||||
_rl_quit_char = _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
|
||||
|
||||
_rl_tty_chars.t_start = tiop->tchars.t_startc;
|
||||
_rl_tty_chars.t_stop = tiop->tchars.t_stopc;
|
||||
_rl_tty_chars.t_eof = tiop->tchars.t_eofc;
|
||||
_rl_tty_chars.t_eol = '\n';
|
||||
_rl_tty_chars.t_eol2 = tiop->tchars.t_brkc;
|
||||
}
|
||||
|
||||
if (tiop->flags & LTCHARS_SET)
|
||||
{
|
||||
_rl_susp_char = _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
|
||||
|
||||
_rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
|
||||
_rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
|
||||
_rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
|
||||
_rl_tty_chars.t_werase = tiop->ltchars.t_werasc;
|
||||
_rl_tty_chars.t_lnext = tiop->ltchars.t_lnextc;
|
||||
}
|
||||
|
||||
_rl_tty_chars.t_status = -1;
|
||||
}
|
||||
|
||||
static int
|
||||
get_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
set_winsize (tty);
|
||||
|
||||
tiop->flags = tiop->lflag = 0;
|
||||
|
||||
errno = 0;
|
||||
if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
|
||||
return -1;
|
||||
tiop->flags |= SGTTY_SET;
|
||||
|
||||
#if defined (TIOCLGET)
|
||||
if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0)
|
||||
tiop->flags |= LFLAG_SET;
|
||||
#endif
|
||||
|
||||
#if defined (TIOCGETC)
|
||||
if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0)
|
||||
tiop->flags |= TCHARS_SET;
|
||||
#endif
|
||||
|
||||
#if defined (TIOCGLTC)
|
||||
if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0)
|
||||
tiop->flags |= LTCHARS_SET;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
set_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
if (tiop->flags & SGTTY_SET)
|
||||
{
|
||||
ioctl (tty, TIOCSETN, &(tiop->sgttyb));
|
||||
tiop->flags &= ~SGTTY_SET;
|
||||
}
|
||||
_rl_echoing_p = 1;
|
||||
|
||||
#if defined (TIOCLSET)
|
||||
if (tiop->flags & LFLAG_SET)
|
||||
{
|
||||
ioctl (tty, TIOCLSET, &(tiop->lflag));
|
||||
tiop->flags &= ~LFLAG_SET;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (TIOCSETC)
|
||||
if (tiop->flags & TCHARS_SET)
|
||||
{
|
||||
ioctl (tty, TIOCSETC, &(tiop->tchars));
|
||||
tiop->flags &= ~TCHARS_SET;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (TIOCSLTC)
|
||||
if (tiop->flags & LTCHARS_SET)
|
||||
{
|
||||
ioctl (tty, TIOCSLTC, &(tiop->ltchars));
|
||||
tiop->flags &= ~LTCHARS_SET;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
prepare_terminal_settings (meta_flag, oldtio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE oldtio, *tiop;
|
||||
{
|
||||
_rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
|
||||
_rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL);
|
||||
|
||||
/* Copy the original settings to the structure we're going to use for
|
||||
our settings. */
|
||||
tiop->sgttyb = oldtio.sgttyb;
|
||||
tiop->lflag = oldtio.lflag;
|
||||
#if defined (TIOCGETC)
|
||||
tiop->tchars = oldtio.tchars;
|
||||
#endif
|
||||
#if defined (TIOCGLTC)
|
||||
tiop->ltchars = oldtio.ltchars;
|
||||
#endif
|
||||
tiop->flags = oldtio.flags;
|
||||
|
||||
/* First, the basic settings to put us into character-at-a-time, no-echo
|
||||
input mode. */
|
||||
tiop->sgttyb.sg_flags &= ~(ECHO | CRMOD);
|
||||
tiop->sgttyb.sg_flags |= CBREAK;
|
||||
|
||||
/* If this terminal doesn't care how the 8th bit is used, then we can
|
||||
use it for the meta-key. If only one of even or odd parity is
|
||||
specified, then the terminal is using parity, and we cannot. */
|
||||
#if !defined (ANYP)
|
||||
# define ANYP (EVENP | ODDP)
|
||||
#endif
|
||||
if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
|
||||
((oldtio.sgttyb.sg_flags & ANYP) == 0))
|
||||
{
|
||||
tiop->sgttyb.sg_flags |= ANYP;
|
||||
|
||||
/* Hack on local mode flags if we can. */
|
||||
#if defined (TIOCLGET)
|
||||
# if defined (LPASS8)
|
||||
tiop->lflag |= LPASS8;
|
||||
# endif /* LPASS8 */
|
||||
#endif /* TIOCLGET */
|
||||
}
|
||||
|
||||
#if defined (TIOCGETC)
|
||||
# if defined (USE_XON_XOFF)
|
||||
/* Get rid of terminal output start and stop characters. */
|
||||
tiop->tchars.t_stopc = -1; /* C-s */
|
||||
tiop->tchars.t_startc = -1; /* C-q */
|
||||
|
||||
/* If there is an XON character, bind it to restart the output. */
|
||||
if (oldtio.tchars.t_startc != -1)
|
||||
rl_bind_key (oldtio.tchars.t_startc, rl_restart_output);
|
||||
# endif /* USE_XON_XOFF */
|
||||
|
||||
/* If there is an EOF char, bind _rl_eof_char to it. */
|
||||
if (oldtio.tchars.t_eofc != -1)
|
||||
_rl_eof_char = oldtio.tchars.t_eofc;
|
||||
|
||||
# if defined (NO_KILL_INTR)
|
||||
/* Get rid of terminal-generated SIGQUIT and SIGINT. */
|
||||
tiop->tchars.t_quitc = -1; /* C-\ */
|
||||
tiop->tchars.t_intrc = -1; /* C-c */
|
||||
# endif /* NO_KILL_INTR */
|
||||
#endif /* TIOCGETC */
|
||||
|
||||
#if defined (TIOCGLTC)
|
||||
/* Make the interrupt keys go away. Just enough to make people happy. */
|
||||
tiop->ltchars.t_dsuspc = -1; /* C-y */
|
||||
tiop->ltchars.t_lnextc = -1; /* C-v */
|
||||
#endif /* TIOCGLTC */
|
||||
}
|
||||
|
||||
#else /* !defined (NEW_TTY_DRIVER) */
|
||||
|
||||
#if !defined (VMIN)
|
||||
# define VMIN VEOF
|
||||
#endif
|
||||
|
||||
#if !defined (VTIME)
|
||||
# define VTIME VEOL
|
||||
#endif
|
||||
|
||||
#if defined (TERMIOS_TTY_DRIVER)
|
||||
# define TIOTYPE struct termios
|
||||
# define DRAIN_OUTPUT(fd) tcdrain (fd)
|
||||
# define GETATTR(tty, tiop) (tcgetattr (tty, tiop))
|
||||
# ifdef M_UNIX
|
||||
# define SETATTR(tty, tiop) (tcsetattr (tty, TCSANOW, tiop))
|
||||
# else
|
||||
# define SETATTR(tty, tiop) (tcsetattr (tty, TCSADRAIN, tiop))
|
||||
# endif /* !M_UNIX */
|
||||
#else
|
||||
# define TIOTYPE struct termio
|
||||
# define DRAIN_OUTPUT(fd)
|
||||
# define GETATTR(tty, tiop) (ioctl (tty, TCGETA, tiop))
|
||||
# define SETATTR(tty, tiop) (ioctl (tty, TCSETAW, tiop))
|
||||
#endif /* !TERMIOS_TTY_DRIVER */
|
||||
|
||||
static TIOTYPE otio;
|
||||
|
||||
static void save_tty_chars PARAMS((TIOTYPE *));
|
||||
static int _get_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int get_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int _set_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int set_tty_settings PARAMS((int, TIOTYPE *));
|
||||
|
||||
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
|
||||
|
||||
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
|
||||
static void _rl_bind_tty_special_chars PARAMS((Keymap, TIOTYPE));
|
||||
|
||||
#if defined (FLUSHO)
|
||||
# define OUTPUT_BEING_FLUSHED(tp) (tp->c_lflag & FLUSHO)
|
||||
#else
|
||||
# define OUTPUT_BEING_FLUSHED(tp) 0
|
||||
#endif
|
||||
|
||||
static void
|
||||
save_tty_chars (tiop)
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
_rl_last_tty_chars = _rl_tty_chars;
|
||||
|
||||
_rl_tty_chars.t_eof = tiop->c_cc[VEOF];
|
||||
_rl_tty_chars.t_eol = tiop->c_cc[VEOL];
|
||||
#ifdef VEOL2
|
||||
_rl_tty_chars.t_eol2 = tiop->c_cc[VEOL2];
|
||||
#endif
|
||||
_rl_tty_chars.t_erase = tiop->c_cc[VERASE];
|
||||
#ifdef VWERASE
|
||||
_rl_tty_chars.t_werase = tiop->c_cc[VWERASE];
|
||||
#endif
|
||||
_rl_tty_chars.t_kill = tiop->c_cc[VKILL];
|
||||
#ifdef VREPRINT
|
||||
_rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
|
||||
#endif
|
||||
_rl_intr_char = _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
|
||||
_rl_quit_char = _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
|
||||
#ifdef VSUSP
|
||||
_rl_susp_char = _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
|
||||
#endif
|
||||
#ifdef VDSUSP
|
||||
_rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
|
||||
#endif
|
||||
#ifdef VSTART
|
||||
_rl_tty_chars.t_start = tiop->c_cc[VSTART];
|
||||
#endif
|
||||
#ifdef VSTOP
|
||||
_rl_tty_chars.t_stop = tiop->c_cc[VSTOP];
|
||||
#endif
|
||||
#ifdef VLNEXT
|
||||
_rl_tty_chars.t_lnext = tiop->c_cc[VLNEXT];
|
||||
#endif
|
||||
#ifdef VDISCARD
|
||||
_rl_tty_chars.t_flush = tiop->c_cc[VDISCARD];
|
||||
#endif
|
||||
#ifdef VSTATUS
|
||||
_rl_tty_chars.t_status = tiop->c_cc[VSTATUS];
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (_AIX) || defined (_AIX41)
|
||||
/* Currently this is only used on AIX */
|
||||
static void
|
||||
rltty_warning (msg)
|
||||
char *msg;
|
||||
{
|
||||
_rl_errmsg ("warning: %s", msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_AIX)
|
||||
void
|
||||
setopost(tp)
|
||||
TIOTYPE *tp;
|
||||
{
|
||||
if ((tp->c_oflag & OPOST) == 0)
|
||||
{
|
||||
_rl_errmsg ("warning: turning on OPOST for terminal\r");
|
||||
tp->c_oflag |= OPOST|ONLCR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
_get_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
int ioctl_ret;
|
||||
|
||||
while (1)
|
||||
{
|
||||
ioctl_ret = GETATTR (tty, tiop);
|
||||
if (ioctl_ret < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
return -1;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
if (OUTPUT_BEING_FLUSHED (tiop))
|
||||
{
|
||||
#if defined (FLUSHO)
|
||||
_rl_errmsg ("warning: turning off output flushing");
|
||||
tiop->c_lflag &= ~FLUSHO;
|
||||
break;
|
||||
#else
|
||||
continue;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
set_winsize (tty);
|
||||
|
||||
errno = 0;
|
||||
if (_get_tty_settings (tty, tiop) < 0)
|
||||
return -1;
|
||||
|
||||
#if defined (_AIX)
|
||||
setopost(tiop);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_set_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
while (SETATTR (tty, tiop) < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
return -1;
|
||||
errno = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
set_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
if (_set_tty_settings (tty, tiop) < 0)
|
||||
return -1;
|
||||
|
||||
#if 0
|
||||
|
||||
#if defined (TERMIOS_TTY_DRIVER)
|
||||
# if defined (__ksr1__)
|
||||
if (ksrflow)
|
||||
{
|
||||
ksrflow = 0;
|
||||
tcflow (tty, TCOON);
|
||||
}
|
||||
# else /* !ksr1 */
|
||||
tcflow (tty, TCOON); /* Simulate a ^Q. */
|
||||
# endif /* !ksr1 */
|
||||
#else
|
||||
ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */
|
||||
#endif /* !TERMIOS_TTY_DRIVER */
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
prepare_terminal_settings (meta_flag, oldtio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE oldtio, *tiop;
|
||||
{
|
||||
_rl_echoing_p = (oldtio.c_lflag & ECHO);
|
||||
#if defined (ECHOCTL)
|
||||
_rl_echoctl = (oldtio.c_lflag & ECHOCTL);
|
||||
#endif
|
||||
|
||||
tiop->c_lflag &= ~(ICANON | ECHO);
|
||||
|
||||
if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
|
||||
_rl_eof_char = oldtio.c_cc[VEOF];
|
||||
|
||||
#if defined (USE_XON_XOFF)
|
||||
#if defined (IXANY)
|
||||
tiop->c_iflag &= ~(IXON | IXANY);
|
||||
#else
|
||||
/* `strict' Posix systems do not define IXANY. */
|
||||
tiop->c_iflag &= ~IXON;
|
||||
#endif /* IXANY */
|
||||
#endif /* USE_XON_XOFF */
|
||||
|
||||
/* Only turn this off if we are using all 8 bits. */
|
||||
if (((tiop->c_cflag & CSIZE) == CS8) || meta_flag)
|
||||
tiop->c_iflag &= ~(ISTRIP | INPCK);
|
||||
|
||||
/* Make sure we differentiate between CR and NL on input. */
|
||||
tiop->c_iflag &= ~(ICRNL | INLCR);
|
||||
|
||||
#if !defined (HANDLE_SIGNALS)
|
||||
tiop->c_lflag &= ~ISIG;
|
||||
#else
|
||||
tiop->c_lflag |= ISIG;
|
||||
#endif
|
||||
|
||||
tiop->c_cc[VMIN] = 1;
|
||||
tiop->c_cc[VTIME] = 0;
|
||||
|
||||
#if defined (FLUSHO)
|
||||
if (OUTPUT_BEING_FLUSHED (tiop))
|
||||
{
|
||||
tiop->c_lflag &= ~FLUSHO;
|
||||
oldtio.c_lflag &= ~FLUSHO;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Turn off characters that we need on Posix systems with job control,
|
||||
just to be sure. This includes ^Y and ^V. This should not really
|
||||
be necessary. */
|
||||
#if defined (TERMIOS_TTY_DRIVER) && defined (_POSIX_VDISABLE)
|
||||
|
||||
#if defined (VLNEXT)
|
||||
tiop->c_cc[VLNEXT] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
|
||||
#if defined (VDSUSP)
|
||||
tiop->c_cc[VDSUSP] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
|
||||
#endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */
|
||||
}
|
||||
#endif /* !NEW_TTY_DRIVER */
|
||||
|
||||
/* Put the terminal in CBREAK mode so that we can detect key presses. */
|
||||
#if defined (NO_TTY_DRIVER)
|
||||
void
|
||||
rl_prep_terminal (meta_flag)
|
||||
int meta_flag;
|
||||
{
|
||||
_rl_echoing_p = 1;
|
||||
}
|
||||
|
||||
void
|
||||
rl_deprep_terminal ()
|
||||
{
|
||||
}
|
||||
|
||||
#else /* ! NO_TTY_DRIVER */
|
||||
void
|
||||
rl_prep_terminal (meta_flag)
|
||||
int meta_flag;
|
||||
{
|
||||
int tty;
|
||||
TIOTYPE tio;
|
||||
|
||||
if (terminal_prepped)
|
||||
return;
|
||||
|
||||
/* Try to keep this function from being INTerrupted. */
|
||||
_rl_block_sigint ();
|
||||
|
||||
tty = rl_instream ? fileno (rl_instream) : fileno (stdin);
|
||||
|
||||
if (get_tty_settings (tty, &tio) < 0)
|
||||
{
|
||||
#if defined (ENOTSUP)
|
||||
/* MacOS X and Linux, at least, lie about the value of errno if
|
||||
tcgetattr fails. */
|
||||
if (errno == ENOTTY || errno == EINVAL || errno == ENOTSUP)
|
||||
#else
|
||||
if (errno == ENOTTY || errno == EINVAL)
|
||||
#endif
|
||||
_rl_echoing_p = 1; /* XXX */
|
||||
|
||||
_rl_release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
otio = tio;
|
||||
|
||||
if (_rl_bind_stty_chars)
|
||||
{
|
||||
#if defined (VI_MODE)
|
||||
/* If editing in vi mode, make sure we restore the bindings in the
|
||||
insertion keymap no matter what keymap we ended up in. */
|
||||
if (rl_editing_mode == vi_mode)
|
||||
rl_tty_unset_default_bindings (vi_insertion_keymap);
|
||||
else
|
||||
#endif
|
||||
rl_tty_unset_default_bindings (_rl_keymap);
|
||||
}
|
||||
save_tty_chars (&otio);
|
||||
RL_SETSTATE(RL_STATE_TTYCSAVED);
|
||||
if (_rl_bind_stty_chars)
|
||||
{
|
||||
#if defined (VI_MODE)
|
||||
/* If editing in vi mode, make sure we set the bindings in the
|
||||
insertion keymap no matter what keymap we ended up in. */
|
||||
if (rl_editing_mode == vi_mode)
|
||||
_rl_bind_tty_special_chars (vi_insertion_keymap, tio);
|
||||
else
|
||||
#endif
|
||||
_rl_bind_tty_special_chars (_rl_keymap, tio);
|
||||
}
|
||||
|
||||
prepare_terminal_settings (meta_flag, otio, &tio);
|
||||
|
||||
if (set_tty_settings (tty, &tio) < 0)
|
||||
{
|
||||
_rl_release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_rl_enable_keypad)
|
||||
_rl_control_keypad (1);
|
||||
|
||||
fflush (rl_outstream);
|
||||
terminal_prepped = 1;
|
||||
RL_SETSTATE(RL_STATE_TERMPREPPED);
|
||||
|
||||
_rl_release_sigint ();
|
||||
}
|
||||
|
||||
/* Restore the terminal's normal settings and modes. */
|
||||
void
|
||||
rl_deprep_terminal ()
|
||||
{
|
||||
int tty;
|
||||
|
||||
if (!terminal_prepped)
|
||||
return;
|
||||
|
||||
/* Try to keep this function from being interrupted. */
|
||||
_rl_block_sigint ();
|
||||
|
||||
tty = rl_instream ? fileno (rl_instream) : fileno (stdin);
|
||||
|
||||
if (_rl_enable_keypad)
|
||||
_rl_control_keypad (0);
|
||||
|
||||
fflush (rl_outstream);
|
||||
|
||||
if (set_tty_settings (tty, &otio) < 0)
|
||||
{
|
||||
_rl_release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
terminal_prepped = 0;
|
||||
RL_UNSETSTATE(RL_STATE_TERMPREPPED);
|
||||
|
||||
_rl_release_sigint ();
|
||||
}
|
||||
#endif /* !NO_TTY_DRIVER */
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Bogus Flow Control */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
int
|
||||
rl_restart_output (count, key)
|
||||
int count, key;
|
||||
{
|
||||
#if defined (__MINGW32__)
|
||||
return 0;
|
||||
#else /* !__MING32__ */
|
||||
|
||||
int fildes = fileno (rl_outstream);
|
||||
#if defined (TIOCSTART)
|
||||
#if defined (apollo)
|
||||
ioctl (&fildes, TIOCSTART, 0);
|
||||
#else
|
||||
ioctl (fildes, TIOCSTART, 0);
|
||||
#endif /* apollo */
|
||||
|
||||
#else /* !TIOCSTART */
|
||||
# if defined (TERMIOS_TTY_DRIVER)
|
||||
# if defined (__ksr1__)
|
||||
if (ksrflow)
|
||||
{
|
||||
ksrflow = 0;
|
||||
tcflow (fildes, TCOON);
|
||||
}
|
||||
# else /* !ksr1 */
|
||||
tcflow (fildes, TCOON); /* Simulate a ^Q. */
|
||||
# endif /* !ksr1 */
|
||||
# else /* !TERMIOS_TTY_DRIVER */
|
||||
# if defined (TCXONC)
|
||||
ioctl (fildes, TCXONC, TCOON);
|
||||
# endif /* TCXONC */
|
||||
# endif /* !TERMIOS_TTY_DRIVER */
|
||||
#endif /* !TIOCSTART */
|
||||
|
||||
return 0;
|
||||
#endif /* !__MINGW32__ */
|
||||
}
|
||||
|
||||
int
|
||||
rl_stop_output (count, key)
|
||||
int count, key;
|
||||
{
|
||||
#if defined (__MINGW32__)
|
||||
return 0;
|
||||
#else
|
||||
|
||||
int fildes = fileno (rl_instream);
|
||||
|
||||
#if defined (TIOCSTOP)
|
||||
# if defined (apollo)
|
||||
ioctl (&fildes, TIOCSTOP, 0);
|
||||
# else
|
||||
ioctl (fildes, TIOCSTOP, 0);
|
||||
# endif /* apollo */
|
||||
#else /* !TIOCSTOP */
|
||||
# if defined (TERMIOS_TTY_DRIVER)
|
||||
# if defined (__ksr1__)
|
||||
ksrflow = 1;
|
||||
# endif /* ksr1 */
|
||||
tcflow (fildes, TCOOFF);
|
||||
# else
|
||||
# if defined (TCXONC)
|
||||
ioctl (fildes, TCXONC, TCOON);
|
||||
# endif /* TCXONC */
|
||||
# endif /* !TERMIOS_TTY_DRIVER */
|
||||
#endif /* !TIOCSTOP */
|
||||
|
||||
return 0;
|
||||
#endif /* !__MINGW32__ */
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Default Key Bindings */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if !defined (NO_TTY_DRIVER)
|
||||
#define SET_SPECIAL(sc, func) set_special_char(kmap, &ttybuff, sc, func)
|
||||
#endif
|
||||
|
||||
#if defined (NO_TTY_DRIVER)
|
||||
|
||||
#define SET_SPECIAL(sc, func)
|
||||
#define RESET_SPECIAL(c)
|
||||
|
||||
#elif defined (NEW_TTY_DRIVER)
|
||||
static void
|
||||
set_special_char (kmap, tiop, sc, func)
|
||||
Keymap kmap;
|
||||
TIOTYPE *tiop;
|
||||
int sc;
|
||||
rl_command_func_t *func;
|
||||
{
|
||||
if (sc != -1 && kmap[(unsigned char)sc].type == ISFUNC)
|
||||
kmap[(unsigned char)sc].function = func;
|
||||
}
|
||||
|
||||
#define RESET_SPECIAL(c) \
|
||||
if (c != -1 && kmap[(unsigned char)c].type == ISFUNC) \
|
||||
kmap[(unsigned char)c].function = rl_insert;
|
||||
|
||||
static void
|
||||
_rl_bind_tty_special_chars (kmap, ttybuff)
|
||||
Keymap kmap;
|
||||
TIOTYPE ttybuff;
|
||||
{
|
||||
if (ttybuff.flags & SGTTY_SET)
|
||||
{
|
||||
SET_SPECIAL (ttybuff.sgttyb.sg_erase, rl_rubout);
|
||||
SET_SPECIAL (ttybuff.sgttyb.sg_kill, rl_unix_line_discard);
|
||||
}
|
||||
|
||||
# if defined (TIOCGLTC)
|
||||
if (ttybuff.flags & LTCHARS_SET)
|
||||
{
|
||||
SET_SPECIAL (ttybuff.ltchars.t_werasc, rl_unix_word_rubout);
|
||||
SET_SPECIAL (ttybuff.ltchars.t_lnextc, rl_quoted_insert);
|
||||
}
|
||||
# endif /* TIOCGLTC */
|
||||
}
|
||||
|
||||
#else /* !NEW_TTY_DRIVER */
|
||||
static void
|
||||
set_special_char (kmap, tiop, sc, func)
|
||||
Keymap kmap;
|
||||
TIOTYPE *tiop;
|
||||
int sc;
|
||||
rl_command_func_t *func;
|
||||
{
|
||||
unsigned char uc;
|
||||
|
||||
uc = tiop->c_cc[sc];
|
||||
if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC)
|
||||
kmap[uc].function = func;
|
||||
}
|
||||
|
||||
/* used later */
|
||||
#define RESET_SPECIAL(uc) \
|
||||
if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC) \
|
||||
kmap[uc].function = rl_insert;
|
||||
|
||||
static void
|
||||
_rl_bind_tty_special_chars (kmap, ttybuff)
|
||||
Keymap kmap;
|
||||
TIOTYPE ttybuff;
|
||||
{
|
||||
SET_SPECIAL (VERASE, rl_rubout);
|
||||
SET_SPECIAL (VKILL, rl_unix_line_discard);
|
||||
|
||||
# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
|
||||
SET_SPECIAL (VLNEXT, rl_quoted_insert);
|
||||
# endif /* VLNEXT && TERMIOS_TTY_DRIVER */
|
||||
|
||||
# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
|
||||
SET_SPECIAL (VWERASE, rl_unix_word_rubout);
|
||||
# endif /* VWERASE && TERMIOS_TTY_DRIVER */
|
||||
}
|
||||
|
||||
#endif /* !NEW_TTY_DRIVER */
|
||||
|
||||
/* Set the system's default editing characters to their readline equivalents
|
||||
in KMAP. Should be static, now that we have rl_tty_set_default_bindings. */
|
||||
void
|
||||
rltty_set_default_bindings (kmap)
|
||||
Keymap kmap;
|
||||
{
|
||||
#if !defined (NO_TTY_DRIVER)
|
||||
TIOTYPE ttybuff;
|
||||
int tty;
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
if (get_tty_settings (tty, &ttybuff) == 0)
|
||||
_rl_bind_tty_special_chars (kmap, ttybuff);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* New public way to set the system default editing chars to their readline
|
||||
equivalents. */
|
||||
void
|
||||
rl_tty_set_default_bindings (kmap)
|
||||
Keymap kmap;
|
||||
{
|
||||
rltty_set_default_bindings (kmap);
|
||||
}
|
||||
|
||||
/* Rebind all of the tty special chars that readline worries about back
|
||||
to self-insert. Call this before saving the current terminal special
|
||||
chars with save_tty_chars(). This only works on POSIX termios or termio
|
||||
systems. */
|
||||
void
|
||||
rl_tty_unset_default_bindings (kmap)
|
||||
Keymap kmap;
|
||||
{
|
||||
/* Don't bother before we've saved the tty special chars at least once. */
|
||||
if (RL_ISSTATE(RL_STATE_TTYCSAVED) == 0)
|
||||
return;
|
||||
|
||||
RESET_SPECIAL (_rl_tty_chars.t_erase);
|
||||
RESET_SPECIAL (_rl_tty_chars.t_kill);
|
||||
|
||||
# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
|
||||
RESET_SPECIAL (_rl_tty_chars.t_lnext);
|
||||
# endif /* VLNEXT && TERMIOS_TTY_DRIVER */
|
||||
|
||||
# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
|
||||
RESET_SPECIAL (_rl_tty_chars.t_werase);
|
||||
# endif /* VWERASE && TERMIOS_TTY_DRIVER */
|
||||
}
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
|
||||
#if defined (NEW_TTY_DRIVER) || defined (NO_TTY_DRIVER)
|
||||
int
|
||||
_rl_disable_tty_signals ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_restore_tty_signals ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
||||
static TIOTYPE sigstty, nosigstty;
|
||||
static int tty_sigs_disabled = 0;
|
||||
|
||||
int
|
||||
_rl_disable_tty_signals ()
|
||||
{
|
||||
if (tty_sigs_disabled)
|
||||
return 0;
|
||||
|
||||
if (_get_tty_settings (fileno (rl_instream), &sigstty) < 0)
|
||||
return -1;
|
||||
|
||||
nosigstty = sigstty;
|
||||
|
||||
nosigstty.c_lflag &= ~ISIG;
|
||||
nosigstty.c_iflag &= ~IXON;
|
||||
|
||||
if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0)
|
||||
return (_set_tty_settings (fileno (rl_instream), &sigstty));
|
||||
|
||||
tty_sigs_disabled = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_restore_tty_signals ()
|
||||
{
|
||||
int r;
|
||||
|
||||
if (tty_sigs_disabled == 0)
|
||||
return 0;
|
||||
|
||||
r = _set_tty_settings (fileno (rl_instream), &sigstty);
|
||||
|
||||
if (r == 0)
|
||||
tty_sigs_disabled = 0;
|
||||
|
||||
return r;
|
||||
}
|
||||
#endif /* !NEW_TTY_DRIVER */
|
||||
|
||||
#endif /* HANDLE_SIGNALS */
|
||||
+2
-1
@@ -744,7 +744,8 @@ pcomp_filename_completion_function (text, state)
|
||||
(rl_completion_found_quote == 0). */
|
||||
iscompgen = this_shell_builtin == compgen_builtin;
|
||||
iscompleting = RL_ISSTATE (RL_STATE_COMPLETING);
|
||||
if (iscompgen && iscompleting == 0 && rl_completion_found_quote == 0)
|
||||
if (iscompgen && iscompleting == 0 && rl_completion_found_quote == 0
|
||||
&& rl_filename_dequoting_function)
|
||||
{
|
||||
/* Use rl_completion_quote_character because any single or
|
||||
double quotes have been removed by the time TEXT makes it
|
||||
|
||||
+1631
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@
|
||||
# here-document tuj-dokumento (info "(bash)Redirections")
|
||||
# indexed array entjerindica tabelo (info "(bash)Arrays")
|
||||
# positional parameter numerparametro ($1 ...) (info "(bash)Positional Parameters")
|
||||
# resolve (symbolic links) elnodigi
|
||||
# special builtin speciala komando (info "(coreutils)Special built-in utilities")
|
||||
# substitution anstataŭigo (info "(bash)Shell Expansions")
|
||||
# unset malvalorizi (variablon); malaktivigi, malŝalti (opcion, nomon)
|
||||
@@ -28,7 +29,7 @@ msgstr ""
|
||||
"Project-Id-Version: GNU bash 4.3-pre2\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2013-03-08 16:00-0500\n"
|
||||
"PO-Revision-Date: 2013-08-18 15:10+0700\n"
|
||||
"PO-Revision-Date: 2013-08-24 14:35+0700\n"
|
||||
"Last-Translator: Sergio Pokrovskij <sergio.pokrovskij@gmail.com>\n"
|
||||
"Language-Team: Esperanto <translation-team-eo@lists.sourceforge.net>\n"
|
||||
"Language: eo\n"
|
||||
@@ -324,12 +325,12 @@ msgstr "Uzeblas nur ene de funkcio"
|
||||
#: builtins/declare.def:311 builtins/declare.def:526
|
||||
#, c-format
|
||||
msgid "%s: reference variable cannot be an array"
|
||||
msgstr "%s: referenca variablo ne povas esti tabelo"
|
||||
msgstr "%s: Referenca variablo ne povas esti tabelo"
|
||||
|
||||
#: builtins/declare.def:317
|
||||
#, c-format
|
||||
msgid "%s: nameref variable self references not allowed"
|
||||
msgstr "%s: nomreferenca variablo ne referencu sin mem"
|
||||
msgstr "%s: Nomreferenca variablo ne referencu sin mem"
|
||||
|
||||
#: builtins/declare.def:415
|
||||
msgid "cannot use `-f' to make functions"
|
||||
@@ -343,7 +344,7 @@ msgstr "%s: Nurlega funkcio"
|
||||
#: builtins/declare.def:565
|
||||
#, c-format
|
||||
msgid "%s: cannot destroy array variables in this way"
|
||||
msgstr "$%s: ĉi tiel ne eblas neniigi variablojn"
|
||||
msgstr "%s: Ĉi tiel ne eblas neniigi tabelvariablojn"
|
||||
|
||||
#: builtins/declare.def:572 builtins/read.def:721
|
||||
#, c-format
|
||||
@@ -952,7 +953,7 @@ msgstr "Eraro en dukto"
|
||||
#: execute_cmd.c:4347
|
||||
#, c-format
|
||||
msgid "%s: maximum function nesting level exceeded (%d)"
|
||||
msgstr "%s: la ingado de funkcioj superis sian maksimumon (%d)"
|
||||
msgstr "%s: La ingado de funkcioj superis sian maksimumon (%d)"
|
||||
|
||||
#: execute_cmd.c:4840
|
||||
#, c-format
|
||||
@@ -2479,6 +2480,7 @@ msgstr ""
|
||||
" alinome."
|
||||
|
||||
# unalias [-a] name [name ...]
|
||||
# unalias [-a] NOMO [NOMO ...]
|
||||
#: builtins.c:276
|
||||
msgid ""
|
||||
"Remove each NAME from the list of defined aliases.\n"
|
||||
@@ -2488,7 +2490,7 @@ msgid ""
|
||||
" \n"
|
||||
" Return success unless a NAME is not an existing alias."
|
||||
msgstr ""
|
||||
"Forigu la nomojn name ... el la listo de difinitaj alinomoj.\n"
|
||||
"Forigu la NOMOjn el la listo de difinitaj alinomoj.\n"
|
||||
"\n"
|
||||
" Opcioj:\n"
|
||||
" -a\tSe enestas la opcio „-a‟, ĉiujn alinomojn forigu.\n"
|
||||
@@ -2662,7 +2664,6 @@ msgstr ""
|
||||
" estas valida."
|
||||
|
||||
# cd:
|
||||
# "resolve symbolic links" -- interpreti? ekstrakti? (-L, -P)??
|
||||
#: builtins.c:385
|
||||
msgid ""
|
||||
"Change the shell working directory.\n"
|
||||
@@ -2698,7 +2699,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Ŝanĝu la kurantan laboran dosierujon de la ŝelo.\n"
|
||||
"\n"
|
||||
" La kuranta dosierujo iĝu DOSIERUJO aŭ, se DOSIERUJO malestas,\n"
|
||||
" La kuranta dosierujo iĝu DOSIERUJO -- aŭ, se DOSIERUJO malestas,\n"
|
||||
" la valoro de la variablo $HOME.\n"
|
||||
"\n"
|
||||
" La variablo $CDPATH difinas la serĉvojon por la dosierujo\n"
|
||||
@@ -2711,16 +2712,15 @@ msgstr ""
|
||||
" variablo havas valoron, tiu valoro estas uzata kiel DOSIERUJO.\n"
|
||||
"\n"
|
||||
" Opcioj:\n"
|
||||
" -L\tsimbolaj ligiloj estu sekvataj: interpretu simbolajn ligilojn\n"
|
||||
" en DOSIERUJO post prilaboro de la aperoj de „..“.\n"
|
||||
" -P\tuzu la fizikan strukturon de dosierujoj sen iri laŭ simbolaj\n"
|
||||
" ligiloj: interpretu simbolajn ligilojn de DOSIERUJO antaŭ ol\n"
|
||||
" prilabori la aperojn de „..“.\n"
|
||||
" -L\tlaŭu simbolajn Ligilojn: en DOSIERUJO, traktu la aperojn de\n"
|
||||
" „..“ antaŭ ol elnodigi la simbolajn ligilojn.\n"
|
||||
" -P\tuzu la Fizikan strukturon de dosierujoj, elnodiginte simbolajn\n"
|
||||
" ligilojn de DOSIERUJO antaŭ ol trakti la aperojn de „..“.\n"
|
||||
" -e eliru kun nenula elirstato se „-P‟ ĉeestas kaj la\n"
|
||||
" kuranta dosierujo ne estas determinebla.\n"
|
||||
"\n"
|
||||
" Defaŭlte la simbolaj ligiloj estas sekvataj, kvazaŭ „-L‟ ĉeestus.\n"
|
||||
" La prilaboro de „..“ konsistas en forigo de la ĵus-antaŭa vojnoma\n"
|
||||
" Defaŭlte la simbolaj ligiloj estas laŭataj, kvazaŭ „-L‟ ĉeestus.\n"
|
||||
" La traktado de „..“ konsistas en forigo de la ĵus-antaŭa vojnoma\n"
|
||||
" ero retrodirekte ĝis la oblikvo „/“ aŭ la komenco de DOSIERUJO.\n"
|
||||
"\n"
|
||||
" Elirstato:\n"
|
||||
@@ -3473,19 +3473,19 @@ msgid ""
|
||||
" Exit Status:\n"
|
||||
" Returns success unless an invalid option is given or an error occurs."
|
||||
msgstr ""
|
||||
"Eligu aŭ redaktu la historiliston\n"
|
||||
"Eligu aŭ redaktu la historiliston.\n"
|
||||
"\n"
|
||||
" Eligu la liston de enigitaj komandoj kun lininumeroj. La ŝanĝitajn\n"
|
||||
" liniojn marku per „*‟. Kun argumento n, eligu nur la ĵusajn\n"
|
||||
" n liniojn.\n"
|
||||
"\n"
|
||||
" Opcioj:\n"
|
||||
" -c\tforviŝu la tutan historion (forigu ĉiujn eroj el la listo)\n"
|
||||
" -c forviŝu la tutan historion (forigu ĉiujn erojn el la listo)\n"
|
||||
" -d forviŝu la linion kies numero estas DEŜOVO\n"
|
||||
"\n"
|
||||
" -a\taldonu la historiliniojn de la kuranta seanco al la\n"
|
||||
" -a aldonu la historiliniojn de la kuranta seanco al la\n"
|
||||
" historidosiero\n"
|
||||
" -n\tlegu ĉiujn ankoraŭ ne legitajn liniojn el la historidosiero\n"
|
||||
" -n legu ĉiujn ankoraŭ ne legitajn liniojn el la historidosiero\n"
|
||||
" kaj aldonu ilin en la historiliston\n"
|
||||
" -r legu la dosieron kaj aldonu ĝian enhavon al la kuranta\n"
|
||||
" historilisto\n"
|
||||
@@ -3985,14 +3985,15 @@ msgstr ""
|
||||
"\tfunkcioj\n"
|
||||
" -H\tEbligu atingi la historion !-stile. Defaŭlte la opcio estas\n"
|
||||
"\taktiva en la dialogaj ŝeloj.\n"
|
||||
" -P\tNe interpretu simbolajn ligilojn plenumante komandojn kiuj\n"
|
||||
" ŝanĝas la kurantan dosierujon („cd‟ ktp)\n"
|
||||
" -P\tLa simbolaj ligiloj estu travideblaj ĉe plenumo de komandoj\n"
|
||||
"\tkiuj ŝanĝas la kurantan dosierujon („cd‟ ktp uzu «fizikan»\n"
|
||||
"\tinterpreton de vojnomo).\n"
|
||||
" -T\tSe aktiva, la DEBUG-kaptilon (DEBUG trap) heredas la ŝelaj\n"
|
||||
"\tfunkcioj\n"
|
||||
" --\tLa restantajn argumentojn uzu por valorizi la numerparametrojn.\n"
|
||||
" Se tiaj argumentoj mankas, malvalorizu la numerparametrojn.\n"
|
||||
"\tSe tiaj argumentoj mankas, malvalorizu la numerparametrojn.\n"
|
||||
" -\tLa restantajn argumentojn uzu por valorizi la numerparametrojn.\n"
|
||||
" La opcioj -x kaj -v malaktiviĝas.\n"
|
||||
"\tLa opcioj -x kaj -v malaktiviĝas.\n"
|
||||
"\n"
|
||||
" Uzante la signon + anstataŭ - vi povas malŝalti la opcion. La\n"
|
||||
" opciojn ankaŭ eblas uzi ĉe la voko de la ŝelo. La kuranta aro da\n"
|
||||
@@ -4541,32 +4542,32 @@ msgid ""
|
||||
" Exit Status:\n"
|
||||
" Returns success unless an invalid option is supplied or an error occurs."
|
||||
msgstr ""
|
||||
"Ŝanĝu risurcolimaĵojn de la ŝelo\n"
|
||||
"Ŝanĝu risurcolimaĵojn de la ŝelo.\n"
|
||||
"\n"
|
||||
" La komando „ulimit‟ ebligas mastrumi la risurcojn disponeblajn al\n"
|
||||
" la procezoj lanĉataj el la ŝelo (se la operaciumo ebligas tion).\n"
|
||||
"\n"
|
||||
" Opcioj:\n"
|
||||
" -S\tŝanĝebla („soft‟) limo\n"
|
||||
" -H\tfirma („hard‟) limo\n"
|
||||
" -a\teligu ĉiujn kurantajn risurcolimaĵojn\n"
|
||||
" -S ŝanĝebla („soft‟) limo\n"
|
||||
" -H firma („hard‟) limo\n"
|
||||
" -a eligu ĉiujn kurantajn risurcolimaĵojn\n"
|
||||
" -b la kontaktoskatola bufrolongo\n"
|
||||
" -c\tmaksimuma longo de nekropsia dosiero („core‟)\n"
|
||||
" -d\tmaksimuma longo de datumsegmento de procezo\n"
|
||||
" -e\tmaksimuma viciga prioritato („nice‟)\n"
|
||||
" -c maksimuma longo de nekropsia dosiero („core‟)\n"
|
||||
" -d maksimuma longo de datumsegmento de procezo\n"
|
||||
" -e maksimuma viciga prioritato („nice‟)\n"
|
||||
" -i maksimuma longo de pendaj signaloj\n"
|
||||
" -f\tmaksimuma longo de dosieroj skribataj de la ŝelo kaj ĝiaj idoj\n"
|
||||
" -l\tmaksimuma longo de ŝlosebla procezmemoro (mlock)\n"
|
||||
" -m\tmaksimuma longo de rezida procezmemoro\n"
|
||||
" -n\tmaksimuma nombro de malfermitaj dosiernumeroj\n"
|
||||
" -p\tlongo de dukta bufro (pipe)\n"
|
||||
" -q\tmaksimuma nombro da bajtoj en atendovicoj de Poziksaj mesaĝoj\n"
|
||||
" -r\tmaksimuma prioritato realtempa\n"
|
||||
" -s\tmaksimuma longo de stako\n"
|
||||
" -t\tmaksimuma tempo ĉefprocesora (en sekundoj)\n"
|
||||
" -u\tmaksimuma nombro de procezoj de la uzanto\n"
|
||||
" -v\tlongo de la virtuala memoro\n"
|
||||
" -x\tmaksimuma nombro de dosierŝlosoj\n"
|
||||
" -f maksimuma longo de dosieroj skribataj de la ŝelo kaj ĝiaj idoj\n"
|
||||
" -l maksimuma longo de ŝlosebla procezmemoro (mlock)\n"
|
||||
" -m maksimuma longo de rezida procezmemoro\n"
|
||||
" -n maksimuma nombro de malfermitaj dosiernumeroj\n"
|
||||
" -p longo de dukta bufro (pipe)\n"
|
||||
" -q maksimuma nombro da bajtoj en atendovicoj de Poziksaj mesaĝoj\n"
|
||||
" -r maksimuma prioritato realtempa\n"
|
||||
" -s maksimuma longo de stako\n"
|
||||
" -t maksimuma tempo ĉefprocesora (en sekundoj)\n"
|
||||
" -u maksimuma nombro de procezoj de la uzanto\n"
|
||||
" -v longo de la virtuala memoro\n"
|
||||
" -x maksimuma nombro de dosierŝlosoj\n"
|
||||
" -T maksimuma nombro de fadenoj\n"
|
||||
"\n"
|
||||
" Ne ĉiuj opcioj disponeblas sur ĉiuj komputilaj platformoj.\n"
|
||||
@@ -5389,7 +5390,7 @@ msgid ""
|
||||
" Returns success unless an invalid option is given or a write or assignment\n"
|
||||
" error occurs."
|
||||
msgstr ""
|
||||
"Aranĝu kaj eligu argumentojn argumentojn laŭ formato\n"
|
||||
"Aranĝu kaj eligu ARGUMENTOJn laŭ FORMATO.\n"
|
||||
"\n"
|
||||
" Opcio:\n"
|
||||
" -v VAR eligu en ŝelvariablon VAR anstataŭ en la ĉefeligujon\n"
|
||||
@@ -5442,14 +5443,14 @@ msgid ""
|
||||
" Exit Status:\n"
|
||||
" Returns success unless an invalid option is supplied or an error occurs."
|
||||
msgstr ""
|
||||
"Difinu, kiel Readline kompletigu argumentojn\n"
|
||||
"Difinu, kiel Readline kompletigu argumentojn.\n"
|
||||
"\n"
|
||||
" Por ĉiu NOMO difinu, kiel la argumentoj estu kompletigotaj. Se\n"
|
||||
" nenia opcio estas donita, eligu la aktualajn \n"
|
||||
" kompletigoregulojn en formo reuzebla por enigo en la ŝelon.\n"
|
||||
"\n"
|
||||
" Opcioj:\n"
|
||||
" -p\tkompletigoregulojn en formo reuzebla por enigo en la ŝelon\n"
|
||||
" -p\teligu kompletigoregulojn en formo uzebla por enigo en la ŝelon\n"
|
||||
" -r\tforigu la kompletigoregulon por ĉiu NOMO, aŭ, se nenia NOMO\n"
|
||||
"\testas donita, ĉiujn kompletigoregulojn\n"
|
||||
" -D apliku la indikitajn kompletigojn kaj agojn Defaŭlte por la\n"
|
||||
|
||||
@@ -717,7 +717,9 @@ set_signal_handler (sig, handler)
|
||||
|
||||
sigemptyset (&act.sa_mask);
|
||||
sigemptyset (&oact.sa_mask);
|
||||
sigaction (sig, &act, &oact);
|
||||
return (oact.sa_handler);
|
||||
if (sigaction (sig, &act, &oact) == 0)
|
||||
return (oact.sa_handler);
|
||||
else
|
||||
return (SIG_DFL);
|
||||
}
|
||||
#endif /* HAVE_POSIX_SIGNALS */
|
||||
|
||||
@@ -0,0 +1,723 @@
|
||||
/* sig.c - interface for shell signal handlers and signal initialization. */
|
||||
|
||||
/* Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "bashtypes.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "bashintl.h"
|
||||
|
||||
#include "shell.h"
|
||||
#if defined (JOB_CONTROL)
|
||||
#include "jobs.h"
|
||||
#endif /* JOB_CONTROL */
|
||||
#include "siglist.h"
|
||||
#include "sig.h"
|
||||
#include "trap.h"
|
||||
|
||||
#include "builtins/common.h"
|
||||
|
||||
#if defined (READLINE)
|
||||
# include "bashline.h"
|
||||
# include <readline/readline.h>
|
||||
#endif
|
||||
|
||||
#if defined (HISTORY)
|
||||
# include "bashhist.h"
|
||||
#endif
|
||||
|
||||
extern int last_command_exit_value;
|
||||
extern int last_command_exit_signal;
|
||||
extern int return_catch_flag;
|
||||
extern int loop_level, continuing, breaking, funcnest;
|
||||
extern int executing_list;
|
||||
extern int comsub_ignore_return;
|
||||
extern int parse_and_execute_level, shell_initialized;
|
||||
#if defined (HISTORY)
|
||||
extern int history_lines_this_session;
|
||||
#endif
|
||||
extern int no_line_editing;
|
||||
|
||||
extern void initialize_siglist ();
|
||||
|
||||
/* Non-zero after SIGINT. */
|
||||
volatile sig_atomic_t interrupt_state = 0;
|
||||
|
||||
/* Non-zero after SIGWINCH */
|
||||
volatile sig_atomic_t sigwinch_received = 0;
|
||||
|
||||
/* Non-zero after SIGTERM */
|
||||
volatile sig_atomic_t sigterm_received = 0;
|
||||
|
||||
/* Set to the value of any terminating signal received. */
|
||||
volatile sig_atomic_t terminating_signal = 0;
|
||||
|
||||
/* The environment at the top-level R-E loop. We use this in
|
||||
the case of error return. */
|
||||
procenv_t top_level;
|
||||
|
||||
#if defined (JOB_CONTROL) || defined (HAVE_POSIX_SIGNALS)
|
||||
/* The signal masks that this shell runs with. */
|
||||
sigset_t top_level_mask;
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
/* When non-zero, we throw_to_top_level (). */
|
||||
int interrupt_immediately = 0;
|
||||
|
||||
/* When non-zero, we call the terminating signal handler immediately. */
|
||||
int terminate_immediately = 0;
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
static SigHandler *old_winch = (SigHandler *)SIG_DFL;
|
||||
#endif
|
||||
|
||||
static void initialize_shell_signals __P((void));
|
||||
|
||||
void
|
||||
initialize_signals (reinit)
|
||||
int reinit;
|
||||
{
|
||||
initialize_shell_signals ();
|
||||
initialize_job_signals ();
|
||||
#if !defined (HAVE_SYS_SIGLIST) && !defined (HAVE_UNDER_SYS_SIGLIST) && !defined (HAVE_STRSIGNAL)
|
||||
if (reinit == 0)
|
||||
initialize_siglist ();
|
||||
#endif /* !HAVE_SYS_SIGLIST && !HAVE_UNDER_SYS_SIGLIST && !HAVE_STRSIGNAL */
|
||||
}
|
||||
|
||||
/* A structure describing a signal that terminates the shell if not
|
||||
caught. The orig_handler member is present so children can reset
|
||||
these signals back to their original handlers. */
|
||||
struct termsig {
|
||||
int signum;
|
||||
SigHandler *orig_handler;
|
||||
int orig_flags;
|
||||
};
|
||||
|
||||
#define NULL_HANDLER (SigHandler *)SIG_DFL
|
||||
|
||||
/* The list of signals that would terminate the shell if not caught.
|
||||
We catch them, but just so that we can write the history file,
|
||||
and so forth. */
|
||||
static struct termsig terminating_signals[] = {
|
||||
#ifdef SIGHUP
|
||||
{ SIGHUP, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGINT
|
||||
{ SIGINT, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGILL
|
||||
{ SIGILL, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGTRAP
|
||||
{ SIGTRAP, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGIOT
|
||||
{ SIGIOT, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGDANGER
|
||||
{ SIGDANGER, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGEMT
|
||||
{ SIGEMT, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGFPE
|
||||
{ SIGFPE, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGBUS
|
||||
{ SIGBUS, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGSEGV
|
||||
{ SIGSEGV, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGSYS
|
||||
{ SIGSYS, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGPIPE
|
||||
{ SIGPIPE, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGALRM
|
||||
{ SIGALRM, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGTERM
|
||||
{ SIGTERM, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGXCPU
|
||||
{ SIGXCPU, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGXFSZ
|
||||
{ SIGXFSZ, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGVTALRM
|
||||
{ SIGVTALRM, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifdef SIGPROF
|
||||
{ SIGPROF, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SIGLOST
|
||||
{ SIGLOST, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGUSR1
|
||||
{ SIGUSR1, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef SIGUSR2
|
||||
{ SIGUSR2, NULL_HANDLER, 0 },
|
||||
#endif
|
||||
};
|
||||
|
||||
#define TERMSIGS_LENGTH (sizeof (terminating_signals) / sizeof (struct termsig))
|
||||
|
||||
#define XSIG(x) (terminating_signals[x].signum)
|
||||
#define XHANDLER(x) (terminating_signals[x].orig_handler)
|
||||
#define XSAFLAGS(x) (terminating_signals[x].orig_flags)
|
||||
|
||||
static int termsigs_initialized = 0;
|
||||
|
||||
/* Initialize signals that will terminate the shell to do some
|
||||
unwind protection. For non-interactive shells, we only call
|
||||
this when a trap is defined for EXIT (0) or when trap is run
|
||||
to display signal dispositions. */
|
||||
void
|
||||
initialize_terminating_signals ()
|
||||
{
|
||||
register int i;
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
struct sigaction act, oact;
|
||||
#endif
|
||||
|
||||
if (termsigs_initialized)
|
||||
return;
|
||||
|
||||
/* The following code is to avoid an expensive call to
|
||||
set_signal_handler () for each terminating_signals. Fortunately,
|
||||
this is possible in Posix. Unfortunately, we have to call signal ()
|
||||
on non-Posix systems for each signal in terminating_signals. */
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
act.sa_handler = termsig_sighandler;
|
||||
act.sa_flags = 0;
|
||||
sigemptyset (&act.sa_mask);
|
||||
sigemptyset (&oact.sa_mask);
|
||||
for (i = 0; i < TERMSIGS_LENGTH; i++)
|
||||
sigaddset (&act.sa_mask, XSIG (i));
|
||||
for (i = 0; i < TERMSIGS_LENGTH; i++)
|
||||
{
|
||||
/* If we've already trapped it, don't do anything. */
|
||||
if (signal_is_trapped (XSIG (i)))
|
||||
continue;
|
||||
|
||||
sigaction (XSIG (i), &act, &oact);
|
||||
XHANDLER(i) = oact.sa_handler;
|
||||
XSAFLAGS(i) = oact.sa_flags;
|
||||
/* Don't do anything with signals that are ignored at shell entry
|
||||
if the shell is not interactive. */
|
||||
/* XXX - should we do this for interactive shells, too? */
|
||||
if (interactive_shell == 0 && XHANDLER (i) == SIG_IGN)
|
||||
{
|
||||
sigaction (XSIG (i), &oact, &act);
|
||||
set_signal_ignored (XSIG (i));
|
||||
}
|
||||
#if defined (SIGPROF) && !defined (_MINIX)
|
||||
if (XSIG (i) == SIGPROF && XHANDLER (i) != SIG_DFL && XHANDLER (i) != SIG_IGN)
|
||||
sigaction (XSIG (i), &oact, (struct sigaction *)NULL);
|
||||
#endif /* SIGPROF && !_MINIX */
|
||||
}
|
||||
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
for (i = 0; i < TERMSIGS_LENGTH; i++)
|
||||
{
|
||||
/* If we've already trapped it, don't do anything. */
|
||||
if (signal_is_trapped (XSIG (i)))
|
||||
continue;
|
||||
|
||||
XHANDLER(i) = signal (XSIG (i), termsig_sighandler);
|
||||
XSAFLAGS(i) = 0;
|
||||
/* Don't do anything with signals that are ignored at shell entry
|
||||
if the shell is not interactive. */
|
||||
/* XXX - should we do this for interactive shells, too? */
|
||||
if (interactive_shell == 0 && XHANDLER (i) == SIG_IGN)
|
||||
{
|
||||
signal (XSIG (i), SIG_IGN);
|
||||
set_signal_ignored (XSIG (i));
|
||||
}
|
||||
#ifdef SIGPROF
|
||||
if (XSIG (i) == SIGPROF && XHANDLER (i) != SIG_DFL && XHANDLER (i) != SIG_IGN)
|
||||
signal (XSIG (i), XHANDLER (i));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
termsigs_initialized = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
initialize_shell_signals ()
|
||||
{
|
||||
if (interactive)
|
||||
initialize_terminating_signals ();
|
||||
|
||||
#if defined (JOB_CONTROL) || defined (HAVE_POSIX_SIGNALS)
|
||||
/* All shells use the signal mask they inherit, and pass it along
|
||||
to child processes. Children will never block SIGCHLD, though. */
|
||||
sigemptyset (&top_level_mask);
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &top_level_mask);
|
||||
# if defined (SIGCHLD)
|
||||
sigdelset (&top_level_mask, SIGCHLD);
|
||||
# endif
|
||||
#endif /* JOB_CONTROL || HAVE_POSIX_SIGNALS */
|
||||
|
||||
/* And, some signals that are specifically ignored by the shell. */
|
||||
set_signal_handler (SIGQUIT, SIG_IGN);
|
||||
|
||||
if (interactive)
|
||||
{
|
||||
set_signal_handler (SIGINT, sigint_sighandler);
|
||||
get_original_signal (SIGTERM);
|
||||
if (signal_is_hard_ignored (SIGTERM) == 0)
|
||||
set_signal_handler (SIGTERM, sigterm_sighandler);
|
||||
set_sigwinch_handler ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
reset_terminating_signals ()
|
||||
{
|
||||
register int i;
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
struct sigaction act;
|
||||
#endif
|
||||
|
||||
if (termsigs_initialized == 0)
|
||||
return;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
act.sa_flags = 0;
|
||||
sigemptyset (&act.sa_mask);
|
||||
for (i = 0; i < TERMSIGS_LENGTH; i++)
|
||||
{
|
||||
/* Skip a signal if it's trapped or handled specially, because the
|
||||
trap code will restore the correct value. */
|
||||
if (signal_is_trapped (XSIG (i)) || signal_is_special (XSIG (i)))
|
||||
continue;
|
||||
|
||||
act.sa_handler = XHANDLER (i);
|
||||
act.sa_flags = XSAFLAGS (i);
|
||||
sigaction (XSIG (i), &act, (struct sigaction *) NULL);
|
||||
}
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
for (i = 0; i < TERMSIGS_LENGTH; i++)
|
||||
{
|
||||
if (signal_is_trapped (XSIG (i)) || signal_is_special (XSIG (i)))
|
||||
continue;
|
||||
|
||||
signal (XSIG (i), XHANDLER (i));
|
||||
}
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
termsigs_initialized = 0;
|
||||
}
|
||||
#undef XSIG
|
||||
#undef XHANDLER
|
||||
|
||||
/* Run some of the cleanups that should be performed when we run
|
||||
jump_to_top_level from a builtin command context. XXX - might want to
|
||||
also call reset_parser here. */
|
||||
void
|
||||
top_level_cleanup ()
|
||||
{
|
||||
/* Clean up string parser environment. */
|
||||
while (parse_and_execute_level)
|
||||
parse_and_execute_cleanup ();
|
||||
|
||||
#if defined (PROCESS_SUBSTITUTION)
|
||||
unlink_fifo_list ();
|
||||
#endif /* PROCESS_SUBSTITUTION */
|
||||
|
||||
run_unwind_protects ();
|
||||
loop_level = continuing = breaking = funcnest = 0;
|
||||
executing_list = comsub_ignore_return = return_catch_flag = 0;
|
||||
}
|
||||
|
||||
/* What to do when we've been interrupted, and it is safe to handle it. */
|
||||
void
|
||||
throw_to_top_level ()
|
||||
{
|
||||
int print_newline = 0;
|
||||
|
||||
if (interrupt_state)
|
||||
{
|
||||
if (last_command_exit_value < 128)
|
||||
last_command_exit_value = 128 + SIGINT;
|
||||
print_newline = 1;
|
||||
DELINTERRUPT;
|
||||
}
|
||||
|
||||
if (interrupt_state)
|
||||
return;
|
||||
|
||||
last_command_exit_signal = (last_command_exit_value > 128) ?
|
||||
(last_command_exit_value - 128) : 0;
|
||||
last_command_exit_value |= 128;
|
||||
|
||||
/* Run any traps set on SIGINT. */
|
||||
run_interrupt_trap ();
|
||||
|
||||
/* Clean up string parser environment. */
|
||||
while (parse_and_execute_level)
|
||||
parse_and_execute_cleanup ();
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
give_terminal_to (shell_pgrp, 0);
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
#if defined (JOB_CONTROL) || defined (HAVE_POSIX_SIGNALS)
|
||||
/* This needs to stay because jobs.c:make_child() uses it without resetting
|
||||
the signal mask. */
|
||||
sigprocmask (SIG_SETMASK, &top_level_mask, (sigset_t *)NULL);
|
||||
#endif
|
||||
|
||||
reset_parser ();
|
||||
|
||||
#if defined (READLINE)
|
||||
if (interactive)
|
||||
bashline_reset ();
|
||||
#endif /* READLINE */
|
||||
|
||||
#if defined (PROCESS_SUBSTITUTION)
|
||||
unlink_fifo_list ();
|
||||
#endif /* PROCESS_SUBSTITUTION */
|
||||
|
||||
run_unwind_protects ();
|
||||
loop_level = continuing = breaking = funcnest = 0;
|
||||
executing_list = comsub_ignore_return = return_catch_flag = 0;
|
||||
|
||||
if (interactive && print_newline)
|
||||
{
|
||||
fflush (stdout);
|
||||
fprintf (stderr, "\n");
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
/* An interrupted `wait' command in a script does not exit the script. */
|
||||
if (interactive || (interactive_shell && !shell_initialized) ||
|
||||
(print_newline && signal_is_trapped (SIGINT)))
|
||||
jump_to_top_level (DISCARD);
|
||||
else
|
||||
jump_to_top_level (EXITPROG);
|
||||
}
|
||||
|
||||
/* This is just here to isolate the longjmp calls. */
|
||||
void
|
||||
jump_to_top_level (value)
|
||||
int value;
|
||||
{
|
||||
longjmp (top_level, value);
|
||||
}
|
||||
|
||||
sighandler
|
||||
termsig_sighandler (sig)
|
||||
int sig;
|
||||
{
|
||||
/* If we get called twice with the same signal before handling it,
|
||||
terminate right away. */
|
||||
if (
|
||||
#ifdef SIGHUP
|
||||
sig != SIGHUP &&
|
||||
#endif
|
||||
#ifdef SIGINT
|
||||
sig != SIGINT &&
|
||||
#endif
|
||||
#ifdef SIGDANGER
|
||||
sig != SIGDANGER &&
|
||||
#endif
|
||||
#ifdef SIGPIPE
|
||||
sig != SIGPIPE &&
|
||||
#endif
|
||||
#ifdef SIGALRM
|
||||
sig != SIGALRM &&
|
||||
#endif
|
||||
#ifdef SIGTERM
|
||||
sig != SIGTERM &&
|
||||
#endif
|
||||
#ifdef SIGXCPU
|
||||
sig != SIGXCPU &&
|
||||
#endif
|
||||
#ifdef SIGXFSZ
|
||||
sig != SIGXFSZ &&
|
||||
#endif
|
||||
#ifdef SIGVTALRM
|
||||
sig != SIGVTALRM &&
|
||||
#endif
|
||||
#ifdef SIGLOST
|
||||
sig != SIGLOST &&
|
||||
#endif
|
||||
#ifdef SIGUSR1
|
||||
sig != SIGUSR1 &&
|
||||
#endif
|
||||
#ifdef SIGUSR2
|
||||
sig != SIGUSR2 &&
|
||||
#endif
|
||||
sig == terminating_signal)
|
||||
terminate_immediately = 1;
|
||||
|
||||
terminating_signal = sig;
|
||||
|
||||
/* XXX - should this also trigger when interrupt_immediately is set? */
|
||||
if (terminate_immediately)
|
||||
{
|
||||
#if defined (HISTORY)
|
||||
/* XXX - will inhibit history file being written */
|
||||
# if defined (READLINE)
|
||||
if (interactive_shell == 0 || interactive == 0 || (sig != SIGHUP && sig != SIGTERM) || no_line_editing || (RL_ISSTATE (RL_STATE_READCMD) == 0))
|
||||
# endif
|
||||
history_lines_this_session = 0;
|
||||
#endif
|
||||
terminate_immediately = 0;
|
||||
termsig_handler (sig);
|
||||
}
|
||||
|
||||
#if defined (READLINE)
|
||||
/* Set the event hook so readline will call it after the signal handlers
|
||||
finish executing, so if this interrupted character input we can get
|
||||
quick response. */
|
||||
if (interactive_shell && interactive && no_line_editing == 0)
|
||||
bashline_set_event_hook ();
|
||||
#endif
|
||||
|
||||
SIGRETURN (0);
|
||||
}
|
||||
|
||||
void
|
||||
termsig_handler (sig)
|
||||
int sig;
|
||||
{
|
||||
static int handling_termsig = 0;
|
||||
|
||||
/* Simple semaphore to keep this function from being executed multiple
|
||||
times. Since we no longer are running as a signal handler, we don't
|
||||
block multiple occurrences of the terminating signals while running. */
|
||||
if (handling_termsig)
|
||||
return;
|
||||
handling_termsig = 1;
|
||||
terminating_signal = 0; /* keep macro from re-testing true. */
|
||||
|
||||
/* I don't believe this condition ever tests true. */
|
||||
if (sig == SIGINT && signal_is_trapped (SIGINT))
|
||||
run_interrupt_trap ();
|
||||
|
||||
#if defined (HISTORY)
|
||||
/* If we don't do something like this, the history will not be saved when
|
||||
an interactive shell is running in a terminal window that gets closed
|
||||
with the `close' button. We can't test for RL_STATE_READCMD because
|
||||
readline no longer handles SIGTERM synchronously. */
|
||||
if (interactive_shell && interactive && (sig == SIGHUP || sig == SIGTERM) && remember_on_history)
|
||||
maybe_save_shell_history ();
|
||||
#endif /* HISTORY */
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
if (sig == SIGHUP && (interactive || (subshell_environment & (SUBSHELL_COMSUB|SUBSHELL_PROCSUB))))
|
||||
hangup_all_jobs ();
|
||||
end_job_control ();
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
#if defined (PROCESS_SUBSTITUTION)
|
||||
unlink_fifo_list ();
|
||||
#endif /* PROCESS_SUBSTITUTION */
|
||||
|
||||
/* Reset execution context */
|
||||
loop_level = continuing = breaking = funcnest = 0;
|
||||
executing_list = comsub_ignore_return = return_catch_flag = 0;
|
||||
|
||||
run_exit_trap (); /* XXX - run exit trap possibly in signal context? */
|
||||
set_signal_handler (sig, SIG_DFL);
|
||||
kill (getpid (), sig);
|
||||
}
|
||||
|
||||
/* What we really do when SIGINT occurs. */
|
||||
sighandler
|
||||
sigint_sighandler (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (MUST_REINSTALL_SIGHANDLERS)
|
||||
signal (sig, sigint_sighandler);
|
||||
#endif
|
||||
|
||||
/* interrupt_state needs to be set for the stack of interrupts to work
|
||||
right. Should it be set unconditionally? */
|
||||
if (interrupt_state == 0)
|
||||
ADDINTERRUPT;
|
||||
|
||||
if (interrupt_immediately)
|
||||
{
|
||||
interrupt_immediately = 0;
|
||||
last_command_exit_value = 128 + sig;
|
||||
throw_to_top_level ();
|
||||
}
|
||||
#if defined (READLINE)
|
||||
/* Set the event hook so readline will call it after the signal handlers
|
||||
finish executing, so if this interrupted character input we can get
|
||||
quick response. */
|
||||
else if (RL_ISSTATE (RL_STATE_SIGHANDLER))
|
||||
bashline_set_event_hook ();
|
||||
#endif
|
||||
|
||||
SIGRETURN (0);
|
||||
}
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
sighandler
|
||||
sigwinch_sighandler (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (MUST_REINSTALL_SIGHANDLERS)
|
||||
set_signal_handler (SIGWINCH, sigwinch_sighandler);
|
||||
#endif /* MUST_REINSTALL_SIGHANDLERS */
|
||||
sigwinch_received = 1;
|
||||
SIGRETURN (0);
|
||||
}
|
||||
#endif /* SIGWINCH */
|
||||
|
||||
void
|
||||
set_sigwinch_handler ()
|
||||
{
|
||||
#if defined (SIGWINCH)
|
||||
old_winch = set_signal_handler (SIGWINCH, sigwinch_sighandler);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
unset_sigwinch_handler ()
|
||||
{
|
||||
#if defined (SIGWINCH)
|
||||
set_signal_handler (SIGWINCH, old_winch);
|
||||
#endif
|
||||
}
|
||||
|
||||
sighandler
|
||||
sigterm_sighandler (sig)
|
||||
int sig;
|
||||
{
|
||||
sigterm_received = 1; /* XXX - counter? */
|
||||
SIGRETURN (0);
|
||||
}
|
||||
|
||||
/* Signal functions used by the rest of the code. */
|
||||
#if !defined (HAVE_POSIX_SIGNALS)
|
||||
|
||||
/* Perform OPERATION on NEWSET, perhaps leaving information in OLDSET. */
|
||||
sigprocmask (operation, newset, oldset)
|
||||
int operation, *newset, *oldset;
|
||||
{
|
||||
int old, new;
|
||||
|
||||
if (newset)
|
||||
new = *newset;
|
||||
else
|
||||
new = 0;
|
||||
|
||||
switch (operation)
|
||||
{
|
||||
case SIG_BLOCK:
|
||||
old = sigblock (new);
|
||||
break;
|
||||
|
||||
case SIG_SETMASK:
|
||||
old = sigsetmask (new);
|
||||
break;
|
||||
|
||||
default:
|
||||
internal_error (_("sigprocmask: %d: invalid operation"), operation);
|
||||
}
|
||||
|
||||
if (oldset)
|
||||
*oldset = old;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if !defined (SA_INTERRUPT)
|
||||
# define SA_INTERRUPT 0
|
||||
#endif
|
||||
|
||||
#if !defined (SA_RESTART)
|
||||
# define SA_RESTART 0
|
||||
#endif
|
||||
|
||||
SigHandler *
|
||||
set_signal_handler (sig, handler)
|
||||
int sig;
|
||||
SigHandler *handler;
|
||||
{
|
||||
struct sigaction act, oact;
|
||||
|
||||
act.sa_handler = handler;
|
||||
act.sa_flags = 0;
|
||||
|
||||
/* XXX - bash-4.2 */
|
||||
/* We don't want a child death to interrupt interruptible system calls, even
|
||||
if we take the time to reap children */
|
||||
#if defined (SIGCHLD)
|
||||
if (sig == SIGCHLD)
|
||||
act.sa_flags |= SA_RESTART; /* XXX */
|
||||
#endif
|
||||
/* If we're installing a SIGTERM handler for interactive shells, we want
|
||||
it to be as close to SIG_IGN as possible. */
|
||||
if (sig == SIGTERM && handler == sigterm_sighandler)
|
||||
act.sa_flags |= SA_RESTART; /* XXX */
|
||||
|
||||
sigemptyset (&act.sa_mask);
|
||||
sigemptyset (&oact.sa_mask);
|
||||
sigaction (sig, &act, &oact);
|
||||
return (oact.sa_handler);
|
||||
}
|
||||
#endif /* HAVE_POSIX_SIGNALS */
|
||||
Reference in New Issue
Block a user