diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-07-12 20:26:32 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-07-12 20:26:32 +0000 |
commit | 7467c8d3b6a50e2cbd8db750963d40b420ad38d1 (patch) | |
tree | 10dcece1e0bb88e35aa95c3a68896ad426e43f7a /shell | |
parent | f69bfc76fa7acb0c87fa3f3b319fde361a8315a8 (diff) | |
download | busybox-w32-7467c8d3b6a50e2cbd8db750963d40b420ad38d1.tar.gz busybox-w32-7467c8d3b6a50e2cbd8db750963d40b420ad38d1.tar.bz2 busybox-w32-7467c8d3b6a50e2cbd8db750963d40b420ad38d1.zip |
Patch from vodz:
Changed email address
cmdedit API change
optimizations for traceroute and md5sum
added a new shared create_icmp_socket() function
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 34 | ||||
-rw-r--r-- | shell/cmdedit.c | 88 | ||||
-rw-r--r-- | shell/cmdedit.h | 2 | ||||
-rw-r--r-- | shell/hush.c | 7 | ||||
-rw-r--r-- | shell/lash.c | 6 | ||||
-rw-r--r-- | shell/msh.c | 12 |
6 files changed, 44 insertions, 105 deletions
diff --git a/shell/ash.c b/shell/ash.c index 985507341..334d2fddd 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -26,7 +26,7 @@ | |||
26 | * package. | 26 | * package. |
27 | * | 27 | * |
28 | * Modified by Erik Andersen <andersee@debian.org> and | 28 | * Modified by Erik Andersen <andersee@debian.org> and |
29 | * Vladimir Oleynik <vodz@usa.net> to be used in busybox | 29 | * Vladimir Oleynik <dzo@simtreas.ru> to be used in busybox |
30 | * | 30 | * |
31 | * | 31 | * |
32 | * Original copyright notice is retained at the end of this file. | 32 | * Original copyright notice is retained at the end of this file. |
@@ -4995,7 +4995,7 @@ err1: | |||
4995 | if (--in.nleft < 0) { | 4995 | if (--in.nleft < 0) { |
4996 | if (in.fd < 0) | 4996 | if (in.fd < 0) |
4997 | break; | 4997 | break; |
4998 | while ((i = read(in.fd, buf, sizeof buf)) < 0 && errno == EINTR); | 4998 | i = safe_read(in.fd, buf, sizeof buf); |
4999 | TRACE(("expbackq: read returns %d\n", i)); | 4999 | TRACE(("expbackq: read returns %d\n", i)); |
5000 | if (i <= 0) | 5000 | if (i <= 0) |
5001 | break; | 5001 | break; |
@@ -6091,10 +6091,8 @@ init(void) { | |||
6091 | * interactive shell and control is returned to the main command loop. | 6091 | * interactive shell and control is returned to the main command loop. |
6092 | */ | 6092 | */ |
6093 | 6093 | ||
6094 | #ifdef ASH_ALIAS | ||
6095 | /* 1 == check for aliases, 2 == also check for assignments */ | 6094 | /* 1 == check for aliases, 2 == also check for assignments */ |
6096 | static int checkalias; | 6095 | static int checkalias; /* also used in no alias mode for check assignments */ |
6097 | #endif | ||
6098 | 6096 | ||
6099 | static void | 6097 | static void |
6100 | reset(void) { | 6098 | reset(void) { |
@@ -6117,9 +6115,7 @@ reset(void) { | |||
6117 | { | 6115 | { |
6118 | tokpushback = 0; | 6116 | tokpushback = 0; |
6119 | checkkwd = 0; | 6117 | checkkwd = 0; |
6120 | #ifdef ASH_ALIAS | ||
6121 | checkalias = 0; | 6118 | checkalias = 0; |
6122 | #endif | ||
6123 | } | 6119 | } |
6124 | 6120 | ||
6125 | /* from redir.c: */ | 6121 | /* from redir.c: */ |
@@ -6137,7 +6133,6 @@ reset(void) { | |||
6137 | */ | 6133 | */ |
6138 | 6134 | ||
6139 | #ifdef BB_FEATURE_COMMAND_EDITING | 6135 | #ifdef BB_FEATURE_COMMAND_EDITING |
6140 | unsigned int shell_context; | ||
6141 | static const char * cmdedit_prompt; | 6136 | static const char * cmdedit_prompt; |
6142 | static inline void putprompt(const char *s) { | 6137 | static inline void putprompt(const char *s) { |
6143 | cmdedit_prompt = s; | 6138 | cmdedit_prompt = s; |
@@ -6206,23 +6201,18 @@ preadfd(void) | |||
6206 | retry: | 6201 | retry: |
6207 | #ifdef BB_FEATURE_COMMAND_EDITING | 6202 | #ifdef BB_FEATURE_COMMAND_EDITING |
6208 | { | 6203 | { |
6209 | if (parsefile->fd) | 6204 | if (!iflag) |
6210 | nr = read(parsefile->fd, buf, BUFSIZ - 1); | 6205 | nr = safe_read(parsefile->fd, buf, BUFSIZ - 1); |
6211 | else { | 6206 | else { |
6212 | do { | ||
6213 | cmdedit_read_input((char*)cmdedit_prompt, buf); | 6207 | cmdedit_read_input((char*)cmdedit_prompt, buf); |
6214 | nr = strlen(buf); | 6208 | nr = strlen(buf); |
6215 | } while (nr <=0 || shell_context); | ||
6216 | cmdedit_terminate(); | ||
6217 | } | 6209 | } |
6218 | } | 6210 | } |
6219 | #else | 6211 | #else |
6220 | nr = read(parsefile->fd, buf, BUFSIZ - 1); | 6212 | nr = safe_read(parsefile->fd, buf, BUFSIZ - 1); |
6221 | #endif | 6213 | #endif |
6222 | 6214 | ||
6223 | if (nr < 0) { | 6215 | if (nr < 0) { |
6224 | if (errno == EINTR) | ||
6225 | goto retry; | ||
6226 | if (parsefile->fd == 0 && errno == EWOULDBLOCK) { | 6216 | if (parsefile->fd == 0 && errno == EWOULDBLOCK) { |
6227 | int flags = fcntl(0, F_GETFL, 0); | 6217 | int flags = fcntl(0, F_GETFL, 0); |
6228 | if (flags >= 0 && flags & O_NONBLOCK) { | 6218 | if (flags >= 0 && flags & O_NONBLOCK) { |
@@ -9872,9 +9862,7 @@ simplecmd() { | |||
9872 | redir = NULL; | 9862 | redir = NULL; |
9873 | rpp = &redir; | 9863 | rpp = &redir; |
9874 | 9864 | ||
9875 | #ifdef ASH_ALIAS | ||
9876 | checkalias = 2; | 9865 | checkalias = 2; |
9877 | #endif | ||
9878 | for (;;) { | 9866 | for (;;) { |
9879 | switch (readtoken()) { | 9867 | switch (readtoken()) { |
9880 | case TWORD: | 9868 | case TWORD: |
@@ -10036,9 +10024,10 @@ peektoken() { | |||
10036 | static int | 10024 | static int |
10037 | readtoken() { | 10025 | readtoken() { |
10038 | int t; | 10026 | int t; |
10027 | |||
10039 | #ifdef ASH_ALIAS | 10028 | #ifdef ASH_ALIAS |
10040 | int savecheckkwd = checkkwd; | ||
10041 | int savecheckalias = checkalias; | 10029 | int savecheckalias = checkalias; |
10030 | int savecheckkwd = checkkwd; | ||
10042 | struct alias *ap; | 10031 | struct alias *ap; |
10043 | #endif | 10032 | #endif |
10044 | 10033 | ||
@@ -10083,13 +10072,14 @@ top: | |||
10083 | } | 10072 | } |
10084 | } | 10073 | } |
10085 | 10074 | ||
10086 | #ifdef ASH_ALIAS | 10075 | |
10087 | if (t != TWORD) { | 10076 | if (t != TWORD) { |
10088 | if (t != TREDIR) { | 10077 | if (t != TREDIR) { |
10089 | checkalias = 0; | 10078 | checkalias = 0; |
10090 | } | 10079 | } |
10091 | } else if (checkalias == 2 && isassignment(wordtext)) { | 10080 | } else if (checkalias == 2 && isassignment(wordtext)) { |
10092 | lasttoken = t = TASSIGN; | 10081 | lasttoken = t = TASSIGN; |
10082 | #ifdef ASH_ALIAS | ||
10093 | } else if (checkalias) { | 10083 | } else if (checkalias) { |
10094 | if (!quoteflag && (ap = lookupalias(wordtext, 1)) != NULL) { | 10084 | if (!quoteflag && (ap = lookupalias(wordtext, 1)) != NULL) { |
10095 | if (*ap->val) { | 10085 | if (*ap->val) { |
@@ -10099,8 +10089,8 @@ top: | |||
10099 | goto top; | 10089 | goto top; |
10100 | } | 10090 | } |
10101 | checkalias = 0; | 10091 | checkalias = 0; |
10102 | } | ||
10103 | #endif | 10092 | #endif |
10093 | } | ||
10104 | out: | 10094 | out: |
10105 | #ifdef DEBUG | 10095 | #ifdef DEBUG |
10106 | if (!alreadyseen) | 10096 | if (!alreadyseen) |
@@ -12927,7 +12917,7 @@ findvar(struct var **vpp, const char *name) | |||
12927 | /* | 12917 | /* |
12928 | * Copyright (c) 1999 Herbert Xu <herbert@debian.org> | 12918 | * Copyright (c) 1999 Herbert Xu <herbert@debian.org> |
12929 | * This file contains code for the times builtin. | 12919 | * This file contains code for the times builtin. |
12930 | * $Id: ash.c,v 1.9 2001/07/10 16:57:09 andersen Exp $ | 12920 | * $Id: ash.c,v 1.10 2001/07/12 20:26:31 andersen Exp $ |
12931 | */ | 12921 | */ |
12932 | static int timescmd (int argc, char **argv) | 12922 | static int timescmd (int argc, char **argv) |
12933 | { | 12923 | { |
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index 4f124d647..540eb7ea7 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * Termios command line History and Editting. | 3 | * Termios command line History and Editting. |
4 | * | 4 | * |
5 | * Copyright (c) 1986-2001 may safely be consumed by a BSD or GPL license. | 5 | * Copyright (c) 1986-2001 may safely be consumed by a BSD or GPL license. |
6 | * Written by: Vladimir Oleynik <vodz@usa.net> | 6 | * Written by: Vladimir Oleynik <dzo@simtreas.ru> |
7 | * | 7 | * |
8 | * Used ideas: | 8 | * Used ideas: |
9 | * Adam Rogoyski <rogoyski@cs.utexas.edu> | 9 | * Adam Rogoyski <rogoyski@cs.utexas.edu> |
@@ -123,9 +123,8 @@ volatile int handlers_sets = 0; /* Set next bites: */ | |||
123 | enum { | 123 | enum { |
124 | SET_ATEXIT = 1, /* when atexit() has been called | 124 | SET_ATEXIT = 1, /* when atexit() has been called |
125 | and get euid,uid,gid to fast compare */ | 125 | and get euid,uid,gid to fast compare */ |
126 | SET_TERM_HANDLERS = 2, /* set many terminates signal handlers */ | 126 | SET_WCHG_HANDLERS = 2, /* winchg signal handler */ |
127 | SET_WCHG_HANDLERS = 4, /* winchg signal handler */ | 127 | SET_RESET_TERM = 4, /* if the terminal needs to be reset upon exit */ |
128 | SET_RESET_TERM = 8, /* if the terminal needs to be reset upon exit */ | ||
129 | }; | 128 | }; |
130 | 129 | ||
131 | 130 | ||
@@ -142,10 +141,6 @@ static | |||
142 | #endif | 141 | #endif |
143 | char *cmdedit_prompt; /* --- "" - - "" - -"- --""-- --""--- */ | 142 | char *cmdedit_prompt; /* --- "" - - "" - -"- --""-- --""--- */ |
144 | 143 | ||
145 | /* Link into lash to reset context to 0 on ^C and such */ | ||
146 | extern unsigned int shell_context; | ||
147 | |||
148 | |||
149 | #ifdef BB_FEATURE_GETUSERNAME_AND_HOMEDIR | 144 | #ifdef BB_FEATURE_GETUSERNAME_AND_HOMEDIR |
150 | static char *user_buf = ""; | 145 | static char *user_buf = ""; |
151 | static char *home_pwd_buf = ""; | 146 | static char *home_pwd_buf = ""; |
@@ -319,6 +314,7 @@ static void put_prompt(void) | |||
319 | out1str(cmdedit_prompt); | 314 | out1str(cmdedit_prompt); |
320 | cmdedit_x = cmdedit_prmt_len; /* count real x terminal position */ | 315 | cmdedit_x = cmdedit_prmt_len; /* count real x terminal position */ |
321 | cursor = 0; | 316 | cursor = 0; |
317 | cmdedit_y = 0; /* new quasireal y */ | ||
322 | } | 318 | } |
323 | 319 | ||
324 | #ifndef BB_FEATURE_SH_FANCY_PROMPT | 320 | #ifndef BB_FEATURE_SH_FANCY_PROMPT |
@@ -456,7 +452,6 @@ static void redraw(int y, int back_cursor) | |||
456 | { | 452 | { |
457 | if (y > 0) /* up to start y */ | 453 | if (y > 0) /* up to start y */ |
458 | printf("\033[%dA", y); | 454 | printf("\033[%dA", y); |
459 | cmdedit_y = 0; /* new quasireal y */ | ||
460 | putchar('\r'); | 455 | putchar('\r'); |
461 | put_prompt(); | 456 | put_prompt(); |
462 | input_end(); /* rewrite */ | 457 | input_end(); /* rewrite */ |
@@ -497,14 +492,6 @@ static void input_forward(void) | |||
497 | } | 492 | } |
498 | 493 | ||
499 | 494 | ||
500 | static void clean_up_and_die(int sig) | ||
501 | { | ||
502 | goto_new_line(); | ||
503 | if (sig != SIGINT) | ||
504 | exit(EXIT_SUCCESS); /* cmdedit_reset_term() called in atexit */ | ||
505 | cmdedit_reset_term(); | ||
506 | } | ||
507 | |||
508 | static void cmdedit_setwidth(int w, int redraw_flg) | 495 | static void cmdedit_setwidth(int w, int redraw_flg) |
509 | { | 496 | { |
510 | cmdedit_termw = cmdedit_prmt_len + 2; | 497 | cmdedit_termw = cmdedit_prmt_len + 2; |
@@ -525,7 +512,7 @@ static void cmdedit_setwidth(int w, int redraw_flg) | |||
525 | } | 512 | } |
526 | } | 513 | } |
527 | 514 | ||
528 | extern void cmdedit_init(void) | 515 | static void cmdedit_init(void) |
529 | { | 516 | { |
530 | cmdedit_prmt_len = 0; | 517 | cmdedit_prmt_len = 0; |
531 | if ((handlers_sets & SET_WCHG_HANDLERS) == 0) { | 518 | if ((handlers_sets & SET_WCHG_HANDLERS) == 0) { |
@@ -557,14 +544,6 @@ extern void cmdedit_init(void) | |||
557 | handlers_sets |= SET_ATEXIT; | 544 | handlers_sets |= SET_ATEXIT; |
558 | atexit(cmdedit_reset_term); /* be sure to do this only once */ | 545 | atexit(cmdedit_reset_term); /* be sure to do this only once */ |
559 | } | 546 | } |
560 | |||
561 | if ((handlers_sets & SET_TERM_HANDLERS) == 0) { | ||
562 | signal(SIGKILL, clean_up_and_die); | ||
563 | signal(SIGINT, clean_up_and_die); | ||
564 | signal(SIGQUIT, clean_up_and_die); | ||
565 | signal(SIGTERM, clean_up_and_die); | ||
566 | handlers_sets |= SET_TERM_HANDLERS; | ||
567 | } | ||
568 | } | 547 | } |
569 | 548 | ||
570 | #ifdef BB_FEATURE_COMMAND_TAB_COMPLETION | 549 | #ifdef BB_FEATURE_COMMAND_TAB_COMPLETION |
@@ -1220,7 +1199,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1220 | 1199 | ||
1221 | fflush(stdout); /* buffered out to fast */ | 1200 | fflush(stdout); /* buffered out to fast */ |
1222 | 1201 | ||
1223 | if (read(0, &c, 1) < 1) | 1202 | if (safe_read(0, &c, 1) < 1) |
1224 | /* if we can't read input then exit */ | 1203 | /* if we can't read input then exit */ |
1225 | goto prepare_to_die; | 1204 | goto prepare_to_die; |
1226 | 1205 | ||
@@ -1241,22 +1220,21 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1241 | break; | 1220 | break; |
1242 | case 3: | 1221 | case 3: |
1243 | /* Control-c -- stop gathering input */ | 1222 | /* Control-c -- stop gathering input */ |
1244 | |||
1245 | /* Link into lash to reset context to 0 on ^C and such */ | ||
1246 | shell_context = 0; | ||
1247 | |||
1248 | /* Go to the next line */ | ||
1249 | goto_new_line(); | 1223 | goto_new_line(); |
1250 | command[0] = 0; | 1224 | command[0] = 0; |
1251 | 1225 | len = 0; | |
1252 | return; | 1226 | lastWasTab = FALSE; |
1227 | put_prompt(); | ||
1228 | break; | ||
1253 | case 4: | 1229 | case 4: |
1254 | /* Control-d -- Delete one character, or exit | 1230 | /* Control-d -- Delete one character, or exit |
1255 | * if the len=0 and no chars to delete */ | 1231 | * if the len=0 and no chars to delete */ |
1256 | if (len == 0) { | 1232 | if (len == 0) { |
1257 | prepare_to_die: | 1233 | prepare_to_die: |
1258 | printf("exit"); | 1234 | printf("exit"); |
1259 | clean_up_and_die(0); | 1235 | goto_new_line(); |
1236 | /* cmdedit_reset_term() called in atexit */ | ||
1237 | exit(EXIT_SUCCESS); | ||
1260 | } else { | 1238 | } else { |
1261 | input_delete(); | 1239 | input_delete(); |
1262 | } | 1240 | } |
@@ -1307,12 +1285,12 @@ prepare_to_die: | |||
1307 | 1285 | ||
1308 | case ESC:{ | 1286 | case ESC:{ |
1309 | /* escape sequence follows */ | 1287 | /* escape sequence follows */ |
1310 | if (read(0, &c, 1) < 1) | 1288 | if (safe_read(0, &c, 1) < 1) |
1311 | return; | 1289 | goto prepare_to_die; |
1312 | /* different vt100 emulations */ | 1290 | /* different vt100 emulations */ |
1313 | if (c == '[' || c == 'O') { | 1291 | if (c == '[' || c == 'O') { |
1314 | if (read(0, &c, 1) < 1) | 1292 | if (safe_read(0, &c, 1) < 1) |
1315 | return; | 1293 | goto prepare_to_die; |
1316 | } | 1294 | } |
1317 | switch (c) { | 1295 | switch (c) { |
1318 | #ifdef BB_FEATURE_COMMAND_TAB_COMPLETION | 1296 | #ifdef BB_FEATURE_COMMAND_TAB_COMPLETION |
@@ -1376,8 +1354,8 @@ prepare_to_die: | |||
1376 | } | 1354 | } |
1377 | if (c >= '1' && c <= '9') | 1355 | if (c >= '1' && c <= '9') |
1378 | do | 1356 | do |
1379 | if (read(0, &c, 1) < 1) | 1357 | if (safe_read(0, &c, 1) < 1) |
1380 | return; | 1358 | goto prepare_to_die; |
1381 | while (c != '~'); | 1359 | while (c != '~'); |
1382 | break; | 1360 | break; |
1383 | } | 1361 | } |
@@ -1386,8 +1364,8 @@ prepare_to_die: | |||
1386 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT | 1364 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT |
1387 | /* Control-V -- Add non-printable symbol */ | 1365 | /* Control-V -- Add non-printable symbol */ |
1388 | if (c == 22) { | 1366 | if (c == 22) { |
1389 | if (read(0, &c, 1) < 1) | 1367 | if (safe_read(0, &c, 1) < 1) |
1390 | return; | 1368 | goto prepare_to_die; |
1391 | if (c == 0) { | 1369 | if (c == 0) { |
1392 | beep(); | 1370 | beep(); |
1393 | break; | 1371 | break; |
@@ -1485,23 +1463,10 @@ prepare_to_die: | |||
1485 | #if defined(BB_FEATURE_SH_FANCY_PROMPT) | 1463 | #if defined(BB_FEATURE_SH_FANCY_PROMPT) |
1486 | free(cmdedit_prompt); | 1464 | free(cmdedit_prompt); |
1487 | #endif | 1465 | #endif |
1488 | return; | 1466 | cmdedit_reset_term(); |
1489 | } | 1467 | } |
1490 | 1468 | ||
1491 | 1469 | ||
1492 | /* Undo the effects of cmdedit_init(). */ | ||
1493 | extern void cmdedit_terminate(void) | ||
1494 | { | ||
1495 | cmdedit_reset_term(); | ||
1496 | if ((handlers_sets & SET_TERM_HANDLERS) != 0) { | ||
1497 | signal(SIGKILL, SIG_DFL); | ||
1498 | signal(SIGINT, SIG_DFL); | ||
1499 | signal(SIGQUIT, SIG_DFL); | ||
1500 | signal(SIGTERM, SIG_DFL); | ||
1501 | signal(SIGWINCH, SIG_DFL); | ||
1502 | handlers_sets &= ~SET_TERM_HANDLERS; | ||
1503 | } | ||
1504 | } | ||
1505 | 1470 | ||
1506 | #endif /* BB_FEATURE_COMMAND_EDITING */ | 1471 | #endif /* BB_FEATURE_COMMAND_EDITING */ |
1507 | 1472 | ||
@@ -1515,8 +1480,6 @@ const char *memory_exhausted = "Memory exhausted"; | |||
1515 | #include <locale.h> | 1480 | #include <locale.h> |
1516 | #endif | 1481 | #endif |
1517 | 1482 | ||
1518 | unsigned int shell_context; | ||
1519 | |||
1520 | int main(int argc, char **argv) | 1483 | int main(int argc, char **argv) |
1521 | { | 1484 | { |
1522 | char buff[BUFSIZ]; | 1485 | char buff[BUFSIZ]; |
@@ -1532,15 +1495,16 @@ int main(int argc, char **argv) | |||
1532 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT | 1495 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT |
1533 | setlocale(LC_ALL, ""); | 1496 | setlocale(LC_ALL, ""); |
1534 | #endif | 1497 | #endif |
1535 | shell_context = 1; | 1498 | while(1) { |
1536 | do { | ||
1537 | int l; | 1499 | int l; |
1538 | cmdedit_read_input(prompt, buff); | 1500 | cmdedit_read_input(prompt, buff); |
1539 | l = strlen(buff); | 1501 | l = strlen(buff); |
1502 | if(l==0) | ||
1503 | break; | ||
1540 | if(l > 0 && buff[l-1] == '\n') | 1504 | if(l > 0 && buff[l-1] == '\n') |
1541 | buff[l-1] = 0; | 1505 | buff[l-1] = 0; |
1542 | printf("*** cmdedit_read_input() returned line =%s=\n", buff); | 1506 | printf("*** cmdedit_read_input() returned line =%s=\n", buff); |
1543 | } while (shell_context); | 1507 | } |
1544 | printf("*** cmdedit_read_input() detect ^C\n"); | 1508 | printf("*** cmdedit_read_input() detect ^C\n"); |
1545 | return 0; | 1509 | return 0; |
1546 | } | 1510 | } |
diff --git a/shell/cmdedit.h b/shell/cmdedit.h index 9e3e44b36..1482da3b8 100644 --- a/shell/cmdedit.h +++ b/shell/cmdedit.h | |||
@@ -1,8 +1,6 @@ | |||
1 | #ifndef CMDEDIT_H | 1 | #ifndef CMDEDIT_H |
2 | #define CMDEDIT_H | 2 | #define CMDEDIT_H |
3 | 3 | ||
4 | void cmdedit_init(void); | ||
5 | void cmdedit_terminate(void); | ||
6 | void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */ | 4 | void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */ |
7 | 5 | ||
8 | #endif /* CMDEDIT_H */ | 6 | #endif /* CMDEDIT_H */ |
diff --git a/shell/hush.c b/shell/hush.c index b74b9d159..134404251 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -237,10 +237,6 @@ unsigned int global_argc; | |||
237 | unsigned int last_return_code; | 237 | unsigned int last_return_code; |
238 | extern char **environ; /* This is in <unistd.h>, but protected with __USE_GNU */ | 238 | extern char **environ; /* This is in <unistd.h>, but protected with __USE_GNU */ |
239 | 239 | ||
240 | /* Variables we export */ | ||
241 | unsigned int shell_context; /* Used in cmdedit.c to reset the | ||
242 | * context when someone hits ^C */ | ||
243 | |||
244 | /* "globals" within this file */ | 240 | /* "globals" within this file */ |
245 | static char *ifs; | 241 | static char *ifs; |
246 | static char map[256]; | 242 | static char map[256]; |
@@ -883,7 +879,6 @@ static void get_user_input(struct in_str *i) | |||
883 | ** child processes (rob@sysgo.de) | 879 | ** child processes (rob@sysgo.de) |
884 | */ | 880 | */ |
885 | cmdedit_read_input(prompt_str, the_command); | 881 | cmdedit_read_input(prompt_str, the_command); |
886 | cmdedit_terminate(); | ||
887 | #else | 882 | #else |
888 | fputs(prompt_str, stdout); | 883 | fputs(prompt_str, stdout); |
889 | fflush(stdout); | 884 | fflush(stdout); |
@@ -1411,6 +1406,7 @@ static int run_pipe_real(struct pipe *pi) | |||
1411 | /* Set the handling for job control signals back to the default. */ | 1406 | /* Set the handling for job control signals back to the default. */ |
1412 | signal(SIGINT, SIG_DFL); | 1407 | signal(SIGINT, SIG_DFL); |
1413 | signal(SIGQUIT, SIG_DFL); | 1408 | signal(SIGQUIT, SIG_DFL); |
1409 | signal(SIGTERM, SIG_DFL); | ||
1414 | signal(SIGTSTP, SIG_DFL); | 1410 | signal(SIGTSTP, SIG_DFL); |
1415 | signal(SIGTTIN, SIG_DFL); | 1411 | signal(SIGTTIN, SIG_DFL); |
1416 | signal(SIGTTOU, SIG_DFL); | 1412 | signal(SIGTTOU, SIG_DFL); |
@@ -2551,6 +2547,7 @@ static void setup_job_control() | |||
2551 | /* Ignore interactive and job-control signals. */ | 2547 | /* Ignore interactive and job-control signals. */ |
2552 | signal(SIGINT, SIG_IGN); | 2548 | signal(SIGINT, SIG_IGN); |
2553 | signal(SIGQUIT, SIG_IGN); | 2549 | signal(SIGQUIT, SIG_IGN); |
2550 | signal(SIGTERM, SIG_IGN); | ||
2554 | signal(SIGTSTP, SIG_IGN); | 2551 | signal(SIGTSTP, SIG_IGN); |
2555 | signal(SIGTTIN, SIG_IGN); | 2552 | signal(SIGTTIN, SIG_IGN); |
2556 | signal(SIGTTOU, SIG_IGN); | 2553 | signal(SIGTTOU, SIG_IGN); |
diff --git a/shell/lash.c b/shell/lash.c index 7c932a910..8f8609534 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -170,9 +170,7 @@ static struct built_in_command bltins_forking[] = { | |||
170 | }; | 170 | }; |
171 | 171 | ||
172 | 172 | ||
173 | /* Variables we export */ | 173 | static int shell_context; /* Type prompt trigger (PS1 or PS2) */ |
174 | unsigned int shell_context; /* Used in cmdedit.c to reset the | ||
175 | context when someone hits ^C */ | ||
176 | 174 | ||
177 | 175 | ||
178 | /* Globals that are static to this file */ | 176 | /* Globals that are static to this file */ |
@@ -716,7 +714,6 @@ static int get_command(FILE * source, char *command) | |||
716 | ** child processes (rob@sysgo.de) | 714 | ** child processes (rob@sysgo.de) |
717 | */ | 715 | */ |
718 | cmdedit_read_input(prompt_str, command); | 716 | cmdedit_read_input(prompt_str, command); |
719 | cmdedit_terminate(); | ||
720 | return 0; | 717 | return 0; |
721 | #else | 718 | #else |
722 | fputs(prompt_str, stdout); | 719 | fputs(prompt_str, stdout); |
@@ -1557,7 +1554,6 @@ int shell_main(int argc_l, char **argv_l) | |||
1557 | 1554 | ||
1558 | /* These variables need re-initializing when recursing */ | 1555 | /* These variables need re-initializing when recursing */ |
1559 | last_jobid = 0; | 1556 | last_jobid = 0; |
1560 | shell_context = 0; | ||
1561 | local_pending_command = NULL; | 1557 | local_pending_command = NULL; |
1562 | close_me_head = NULL; | 1558 | close_me_head = NULL; |
1563 | job_list.head = NULL; | 1559 | job_list.head = NULL; |
diff --git a/shell/msh.c b/shell/msh.c index 230d74f5a..8f046e794 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -682,8 +682,7 @@ static void * brkaddr; | |||
682 | 682 | ||
683 | 683 | ||
684 | #ifdef BB_FEATURE_COMMAND_EDITING | 684 | #ifdef BB_FEATURE_COMMAND_EDITING |
685 | char * current_prompt; | 685 | static char * current_prompt; |
686 | unsigned int shell_context; | ||
687 | #endif | 686 | #endif |
688 | 687 | ||
689 | 688 | ||
@@ -4449,9 +4448,7 @@ register struct ioarg *ap; | |||
4449 | if ((i = ap->afid != bp->id) || bp->bufp == bp->ebufp) { | 4448 | if ((i = ap->afid != bp->id) || bp->bufp == bp->ebufp) { |
4450 | if (i) | 4449 | if (i) |
4451 | lseek(ap->afile, ap->afpos, 0); | 4450 | lseek(ap->afile, ap->afpos, 0); |
4452 | do { | 4451 | i = safe_read(ap->afile, bp->buf, sizeof(bp->buf)); |
4453 | i = read(ap->afile, bp->buf, sizeof(bp->buf)); | ||
4454 | } while (i < 0 && errno == EINTR); | ||
4455 | if (i <= 0) { | 4452 | if (i <= 0) { |
4456 | closef(ap->afile); | 4453 | closef(ap->afile); |
4457 | return 0; | 4454 | return 0; |
@@ -4470,7 +4467,6 @@ register struct ioarg *ap; | |||
4470 | 4467 | ||
4471 | while (size == 0 || position >= size) { | 4468 | while (size == 0 || position >= size) { |
4472 | cmdedit_read_input(current_prompt, mycommand); | 4469 | cmdedit_read_input(current_prompt, mycommand); |
4473 | cmdedit_terminate(); | ||
4474 | size = strlen(mycommand); | 4470 | size = strlen(mycommand); |
4475 | position = 0; | 4471 | position = 0; |
4476 | } | 4472 | } |
@@ -4480,9 +4476,7 @@ register struct ioarg *ap; | |||
4480 | } else | 4476 | } else |
4481 | #endif | 4477 | #endif |
4482 | { | 4478 | { |
4483 | do { | 4479 | i = safe_read(ap->afile, &c, sizeof(c)); |
4484 | i = read(ap->afile, &c, sizeof(c)); | ||
4485 | } while (i < 0 && errno == EINTR); | ||
4486 | return(i == sizeof(c)? c&0177: (closef(ap->afile), 0)); | 4480 | return(i == sizeof(c)? c&0177: (closef(ap->afile), 0)); |
4487 | } | 4481 | } |
4488 | } | 4482 | } |