| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: histedit.c,v 1.41 2008/02/13 12:57:16 joerg Exp $ */ | | 1 | /* $NetBSD: histedit.c,v 1.42 2011/01/07 22:21:56 jmmv Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1993 | | 4 | * Copyright (c) 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Kenneth Almquist. | | 8 | * Kenneth Almquist. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -27,27 +27,27 @@ | | | @@ -27,27 +27,27 @@ |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <sys/cdefs.h> | | 35 | #include <sys/cdefs.h> |
36 | #ifndef lint | | 36 | #ifndef lint |
37 | #if 0 | | 37 | #if 0 |
38 | static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95"; | | 38 | static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95"; |
39 | #else | | 39 | #else |
40 | __RCSID("$NetBSD: histedit.c,v 1.41 2008/02/13 12:57:16 joerg Exp $"); | | 40 | __RCSID("$NetBSD: histedit.c,v 1.42 2011/01/07 22:21:56 jmmv Exp $"); |
41 | #endif | | 41 | #endif |
42 | #endif /* not lint */ | | 42 | #endif /* not lint */ |
43 | | | 43 | |
44 | #include <sys/param.h> | | 44 | #include <sys/param.h> |
45 | #include <paths.h> | | 45 | #include <paths.h> |
46 | #include <stdio.h> | | 46 | #include <stdio.h> |
47 | #include <stdlib.h> | | 47 | #include <stdlib.h> |
48 | #include <unistd.h> | | 48 | #include <unistd.h> |
49 | /* | | 49 | /* |
50 | * Editline and history functions (and glue). | | 50 | * Editline and history functions (and glue). |
51 | */ | | 51 | */ |
52 | #include "shell.h" | | 52 | #include "shell.h" |
53 | #include "parser.h" | | 53 | #include "parser.h" |
| @@ -139,33 +139,33 @@ histedit(void) | | | @@ -139,33 +139,33 @@ histedit(void) |
139 | _el_fn_complete); | | 139 | _el_fn_complete); |
140 | } else { | | 140 | } else { |
141 | bad: | | 141 | bad: |
142 | out2str("sh: can't initialize editing\n"); | | 142 | out2str("sh: can't initialize editing\n"); |
143 | } | | 143 | } |
144 | INTON; | | 144 | INTON; |
145 | } else if (!editing && el) { | | 145 | } else if (!editing && el) { |
146 | INTOFF; | | 146 | INTOFF; |
147 | el_end(el); | | 147 | el_end(el); |
148 | el = NULL; | | 148 | el = NULL; |
149 | INTON; | | 149 | INTON; |
150 | } | | 150 | } |
151 | if (el) { | | 151 | if (el) { |
| | | 152 | el_source(el, NULL); |
152 | if (Vflag) | | 153 | if (Vflag) |
153 | el_set(el, EL_EDITOR, "vi"); | | 154 | el_set(el, EL_EDITOR, "vi"); |
154 | else if (Eflag) | | 155 | else if (Eflag) |
155 | el_set(el, EL_EDITOR, "emacs"); | | 156 | el_set(el, EL_EDITOR, "emacs"); |
156 | el_set(el, EL_BIND, "^I", | | 157 | el_set(el, EL_BIND, "^I", |
157 | tabcomplete ? "rl-complete" : "ed-insert", NULL); | | 158 | tabcomplete ? "rl-complete" : "ed-insert", NULL); |
158 | el_source(el, NULL); | | | |
159 | } | | 159 | } |
160 | } else { | | 160 | } else { |
161 | INTOFF; | | 161 | INTOFF; |
162 | if (el) { /* no editing if not interactive */ | | 162 | if (el) { /* no editing if not interactive */ |
163 | el_end(el); | | 163 | el_end(el); |
164 | el = NULL; | | 164 | el = NULL; |
165 | } | | 165 | } |
166 | if (hist) { | | 166 | if (hist) { |
167 | history_end(hist); | | 167 | history_end(hist); |
168 | hist = NULL; | | 168 | hist = NULL; |
169 | } | | 169 | } |
170 | INTON; | | 170 | INTON; |
171 | } | | 171 | } |