diff options
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/shell/ash.c b/shell/ash.c index dcaac1fd8..89e70c1ee 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -1093,7 +1093,7 @@ struct strpush { | |||
1093 | struct parsefile { | 1093 | struct parsefile { |
1094 | struct parsefile *prev; /* preceding file on stack */ | 1094 | struct parsefile *prev; /* preceding file on stack */ |
1095 | int linno; /* current line */ | 1095 | int linno; /* current line */ |
1096 | int fd; /* file descriptor (or -1 if string) */ | 1096 | int pf_fd; /* file descriptor (or -1 if string) */ |
1097 | int left_in_line; /* number of chars left in this line */ | 1097 | int left_in_line; /* number of chars left in this line */ |
1098 | int left_in_buffer; /* number of chars left in this buffer past the line */ | 1098 | int left_in_buffer; /* number of chars left in this buffer past the line */ |
1099 | char *next_to_pgetc; /* next char in buffer */ | 1099 | char *next_to_pgetc; /* next char in buffer */ |
@@ -1119,7 +1119,7 @@ ash_vmsg(const char *msg, va_list ap) | |||
1119 | if (commandname) { | 1119 | if (commandname) { |
1120 | if (strcmp(arg0, commandname)) | 1120 | if (strcmp(arg0, commandname)) |
1121 | fprintf(stderr, "%s: ", commandname); | 1121 | fprintf(stderr, "%s: ", commandname); |
1122 | if (!iflag || g_parsefile->fd > 0) | 1122 | if (!iflag || g_parsefile->pf_fd > 0) |
1123 | fprintf(stderr, "line %d: ", startlinno); | 1123 | fprintf(stderr, "line %d: ", startlinno); |
1124 | } | 1124 | } |
1125 | vfprintf(stderr, msg, ap); | 1125 | vfprintf(stderr, msg, ap); |
@@ -5356,15 +5356,15 @@ static int is_hidden_fd(struct redirtab *rp, int fd) | |||
5356 | /* Check open scripts' fds */ | 5356 | /* Check open scripts' fds */ |
5357 | pf = g_parsefile; | 5357 | pf = g_parsefile; |
5358 | while (pf) { | 5358 | while (pf) { |
5359 | /* We skip fd == 0 case because of the following case: | 5359 | /* We skip pf_fd == 0 case because of the following case: |
5360 | * $ ash # running ash interactively | 5360 | * $ ash # running ash interactively |
5361 | * $ . ./script.sh | 5361 | * $ . ./script.sh |
5362 | * and in script.sh: "exec 9>&0". | 5362 | * and in script.sh: "exec 9>&0". |
5363 | * Even though top-level fd _is_ 0, | 5363 | * Even though top-level pf_fd _is_ 0, |
5364 | * it's still ok to use it: "read" builtin uses it, | 5364 | * it's still ok to use it: "read" builtin uses it, |
5365 | * why should we cripple "exec" builtin? | 5365 | * why should we cripple "exec" builtin? |
5366 | */ | 5366 | */ |
5367 | if (pf->fd > 0 && fd == pf->fd) { | 5367 | if (pf->pf_fd > 0 && fd == pf->pf_fd) { |
5368 | return 1; | 5368 | return 1; |
5369 | } | 5369 | } |
5370 | pf = pf->prev; | 5370 | pf = pf->prev; |
@@ -9921,8 +9921,8 @@ preadfd(void) | |||
9921 | g_parsefile->next_to_pgetc = buf; | 9921 | g_parsefile->next_to_pgetc = buf; |
9922 | #if ENABLE_FEATURE_EDITING | 9922 | #if ENABLE_FEATURE_EDITING |
9923 | retry: | 9923 | retry: |
9924 | if (!iflag || g_parsefile->fd != STDIN_FILENO) | 9924 | if (!iflag || g_parsefile->pf_fd != STDIN_FILENO) |
9925 | nr = nonblock_safe_read(g_parsefile->fd, buf, IBUFSIZ - 1); | 9925 | nr = nonblock_safe_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1); |
9926 | else { | 9926 | else { |
9927 | #if ENABLE_FEATURE_TAB_COMPLETION | 9927 | #if ENABLE_FEATURE_TAB_COMPLETION |
9928 | line_input_state->path_lookup = pathval(); | 9928 | line_input_state->path_lookup = pathval(); |
@@ -9944,7 +9944,7 @@ preadfd(void) | |||
9944 | } | 9944 | } |
9945 | } | 9945 | } |
9946 | #else | 9946 | #else |
9947 | nr = nonblock_safe_read(g_parsefile->fd, buf, IBUFSIZ - 1); | 9947 | nr = nonblock_safe_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1); |
9948 | #endif | 9948 | #endif |
9949 | 9949 | ||
9950 | #if 0 | 9950 | #if 0 |
@@ -10171,7 +10171,7 @@ pushfile(void) | |||
10171 | 10171 | ||
10172 | pf = ckzalloc(sizeof(*pf)); | 10172 | pf = ckzalloc(sizeof(*pf)); |
10173 | pf->prev = g_parsefile; | 10173 | pf->prev = g_parsefile; |
10174 | pf->fd = -1; | 10174 | pf->pf_fd = -1; |
10175 | /*pf->strpush = NULL; - ckzalloc did it */ | 10175 | /*pf->strpush = NULL; - ckzalloc did it */ |
10176 | /*pf->basestrpush.prev = NULL;*/ | 10176 | /*pf->basestrpush.prev = NULL;*/ |
10177 | g_parsefile = pf; | 10177 | g_parsefile = pf; |
@@ -10183,8 +10183,8 @@ popfile(void) | |||
10183 | struct parsefile *pf = g_parsefile; | 10183 | struct parsefile *pf = g_parsefile; |
10184 | 10184 | ||
10185 | INT_OFF; | 10185 | INT_OFF; |
10186 | if (pf->fd >= 0) | 10186 | if (pf->pf_fd >= 0) |
10187 | close(pf->fd); | 10187 | close(pf->pf_fd); |
10188 | free(pf->buf); | 10188 | free(pf->buf); |
10189 | while (pf->strpush) | 10189 | while (pf->strpush) |
10190 | popstring(); | 10190 | popstring(); |
@@ -10211,9 +10211,9 @@ static void | |||
10211 | closescript(void) | 10211 | closescript(void) |
10212 | { | 10212 | { |
10213 | popallfiles(); | 10213 | popallfiles(); |
10214 | if (g_parsefile->fd > 0) { | 10214 | if (g_parsefile->pf_fd > 0) { |
10215 | close(g_parsefile->fd); | 10215 | close(g_parsefile->pf_fd); |
10216 | g_parsefile->fd = 0; | 10216 | g_parsefile->pf_fd = 0; |
10217 | } | 10217 | } |
10218 | } | 10218 | } |
10219 | 10219 | ||
@@ -10229,7 +10229,7 @@ setinputfd(int fd, int push) | |||
10229 | pushfile(); | 10229 | pushfile(); |
10230 | g_parsefile->buf = NULL; | 10230 | g_parsefile->buf = NULL; |
10231 | } | 10231 | } |
10232 | g_parsefile->fd = fd; | 10232 | g_parsefile->pf_fd = fd; |
10233 | if (g_parsefile->buf == NULL) | 10233 | if (g_parsefile->buf == NULL) |
10234 | g_parsefile->buf = ckmalloc(IBUFSIZ); | 10234 | g_parsefile->buf = ckmalloc(IBUFSIZ); |
10235 | g_parsefile->left_in_buffer = 0; | 10235 | g_parsefile->left_in_buffer = 0; |
@@ -13562,7 +13562,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
13562 | * Ensure we don't falsely claim that 0 (stdin) | 13562 | * Ensure we don't falsely claim that 0 (stdin) |
13563 | * is one of stacked source fds. | 13563 | * is one of stacked source fds. |
13564 | * Testcase: ash -c 'exec 1>&0' must not complain. */ | 13564 | * Testcase: ash -c 'exec 1>&0' must not complain. */ |
13565 | // if (!sflag) g_parsefile->fd = -1; | 13565 | // if (!sflag) g_parsefile->pf_fd = -1; |
13566 | // ^^ not necessary since now we special-case fd 0 | 13566 | // ^^ not necessary since now we special-case fd 0 |
13567 | // in is_hidden_fd() to not be considered "hidden fd" | 13567 | // in is_hidden_fd() to not be considered "hidden fd" |
13568 | evalstring(minusc, 0); | 13568 | evalstring(minusc, 0); |