aboutsummaryrefslogtreecommitdiff
path: root/ash.c
diff options
context:
space:
mode:
Diffstat (limited to 'ash.c')
-rw-r--r--ash.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/ash.c b/ash.c
index 985507341..334d2fddd 100644
--- a/ash.c
+++ b/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 */
6096static int checkalias; 6095static int checkalias; /* also used in no alias mode for check assignments */
6097#endif
6098 6096
6099static void 6097static void
6100reset(void) { 6098reset(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
6140unsigned int shell_context;
6141static const char * cmdedit_prompt; 6136static const char * cmdedit_prompt;
6142static inline void putprompt(const char *s) { 6137static inline void putprompt(const char *s) {
6143 cmdedit_prompt = s; 6138 cmdedit_prompt = s;
@@ -6206,23 +6201,18 @@ preadfd(void)
6206retry: 6201retry:
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() {
10036static int 10024static int
10037readtoken() { 10025readtoken() {
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 }
10104out: 10094out:
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 */
12932static int timescmd (int argc, char **argv) 12922static int timescmd (int argc, char **argv)
12933{ 12923{