diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2009-04-23 00:14:32 +1000 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2009-04-23 04:44:42 +1000 |
commit | 504026949bb07100cce1a019a2867e150344e8b2 (patch) | |
tree | 1522e8063d508489d94855a1916b30322b8f5aa3 /shell | |
parent | 2b799037c73b95cbf7dd392527947bd5a711083f (diff) | |
download | busybox-w32-504026949bb07100cce1a019a2867e150344e8b2.tar.gz busybox-w32-504026949bb07100cce1a019a2867e150344e8b2.tar.bz2 busybox-w32-504026949bb07100cce1a019a2867e150344e8b2.zip |
shell/ash: massive ifdefs to unrelevant remove code
This does not mean that it compiles. But at least it makes later patches
easier to see.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 107 |
1 files changed, 104 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c index ea10a65cf..5303e15da 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -29,6 +29,9 @@ | |||
29 | * rewrote arith (see notes to this), added locale support, | 29 | * rewrote arith (see notes to this), added locale support, |
30 | * rewrote dynamic variables. | 30 | * rewrote dynamic variables. |
31 | * | 31 | * |
32 | * Modified by Nguyễn Thái Ngọc Duy <pclouds@gmail.com> (c) 2007-2009 | ||
33 | * to be able to use on MS Windows platform. | ||
34 | * | ||
32 | */ | 35 | */ |
33 | 36 | ||
34 | /* | 37 | /* |
@@ -50,22 +53,52 @@ | |||
50 | #define JOBS 0 | 53 | #define JOBS 0 |
51 | #endif | 54 | #endif |
52 | 55 | ||
56 | #ifndef __MINGW32__ | ||
53 | #if DEBUG | 57 | #if DEBUG |
54 | #define _GNU_SOURCE | 58 | #define _GNU_SOURCE |
55 | #endif | 59 | #endif |
56 | #include "busybox.h" /* for struct bb_applet */ | ||
57 | #include <paths.h> | 60 | #include <paths.h> |
61 | #endif | ||
58 | #include <setjmp.h> | 62 | #include <setjmp.h> |
59 | #include <fnmatch.h> | 63 | #include <fnmatch.h> |
64 | #include "busybox.h" /* for struct bb_applet */ | ||
60 | #if JOBS || ENABLE_ASH_READ_NCHARS | 65 | #if JOBS || ENABLE_ASH_READ_NCHARS |
61 | #include <termios.h> | 66 | #include <termios.h> |
62 | #endif | 67 | #endif |
68 | #ifndef __MINGW32__ | ||
63 | extern char **environ; | 69 | extern char **environ; |
70 | #endif | ||
64 | 71 | ||
65 | #if defined(__uClinux__) | 72 | #if defined(__uClinux__) |
66 | #error "Do not even bother, ash will not run on uClinux" | 73 | #error "Do not even bother, ash will not run on uClinux" |
67 | #endif | 74 | #endif |
68 | 75 | ||
76 | #ifdef __MINGW32__ | ||
77 | #include "run-command.h" | ||
78 | #include "ash_mingw.h" | ||
79 | #include <malloc.h> | ||
80 | static const char * updatepwd(const char *dir); | ||
81 | static int openhere(union node *redir); | ||
82 | static int | ||
83 | waitcmd(int argc, char **argv) | ||
84 | { | ||
85 | return 0; | ||
86 | } | ||
87 | static int | ||
88 | ulimitcmd(int argc, char **argv) | ||
89 | { | ||
90 | return 0; | ||
91 | } | ||
92 | static int stoppedjobs() | ||
93 | { | ||
94 | return 0; | ||
95 | } | ||
96 | static int | ||
97 | timescmd(int ac, char **av) | ||
98 | { | ||
99 | return 0; | ||
100 | } | ||
101 | #endif | ||
69 | 102 | ||
70 | /* ============ Misc helpers */ | 103 | /* ============ Misc helpers */ |
71 | 104 | ||
@@ -233,13 +266,17 @@ static void | |||
233 | raise_interrupt(void) | 266 | raise_interrupt(void) |
234 | { | 267 | { |
235 | int i; | 268 | int i; |
269 | #ifndef __MINGW32__ | ||
236 | sigset_t mask; | 270 | sigset_t mask; |
271 | #endif | ||
237 | 272 | ||
238 | intpending = 0; | 273 | intpending = 0; |
239 | /* Signal is not automatically re-enabled after it is raised, | 274 | /* Signal is not automatically re-enabled after it is raised, |
240 | * do it ourself */ | 275 | * do it ourself */ |
276 | #ifndef __MINGW32__ | ||
241 | sigemptyset(&mask); | 277 | sigemptyset(&mask); |
242 | sigprocmask(SIG_SETMASK, &mask, 0); | 278 | sigprocmask(SIG_SETMASK, &mask, 0); |
279 | #endif | ||
243 | /* pendingsig = 0; - now done in onsig() */ | 280 | /* pendingsig = 0; - now done in onsig() */ |
244 | 281 | ||
245 | i = EXSIG; | 282 | i = EXSIG; |
@@ -306,6 +343,7 @@ force_int_on(void) | |||
306 | } while (0) | 343 | } while (0) |
307 | /* EXSIG is turned off by evalbltin(). */ | 344 | /* EXSIG is turned off by evalbltin(). */ |
308 | 345 | ||
346 | #ifndef __MINGW32__ | ||
309 | /* | 347 | /* |
310 | * Ignore a signal. Only one usage site - in forkchild() | 348 | * Ignore a signal. Only one usage site - in forkchild() |
311 | */ | 349 | */ |
@@ -336,6 +374,7 @@ onsig(int signo) | |||
336 | } | 374 | } |
337 | } | 375 | } |
338 | 376 | ||
377 | #endif | ||
339 | 378 | ||
340 | /* ============ Stdout/stderr output */ | 379 | /* ============ Stdout/stderr output */ |
341 | 380 | ||
@@ -698,9 +737,11 @@ static void | |||
698 | opentrace(void) | 737 | opentrace(void) |
699 | { | 738 | { |
700 | char s[100]; | 739 | char s[100]; |
740 | #ifndef __MINGW32__ | ||
701 | #ifdef O_APPEND | 741 | #ifdef O_APPEND |
702 | int flags; | 742 | int flags; |
703 | #endif | 743 | #endif |
744 | #endif | ||
704 | 745 | ||
705 | if (debug != 1) { | 746 | if (debug != 1) { |
706 | if (tracefile) | 747 | if (tracefile) |
@@ -723,12 +764,14 @@ opentrace(void) | |||
723 | return; | 764 | return; |
724 | } | 765 | } |
725 | } | 766 | } |
767 | #ifndef __MINGW32__ | ||
726 | #ifdef O_APPEND | 768 | #ifdef O_APPEND |
727 | flags = fcntl(fileno(tracefile), F_GETFL, 0); | 769 | flags = fcntl(fileno(tracefile), F_GETFL, 0); |
728 | if (flags >= 0) | 770 | if (flags >= 0) |
729 | fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND); | 771 | fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND); |
730 | #endif | 772 | #endif |
731 | setlinebuf(tracefile); | 773 | setlinebuf(tracefile); |
774 | #endif | ||
732 | fputs("\nTracing started.\n", tracefile); | 775 | fputs("\nTracing started.\n", tracefile); |
733 | } | 776 | } |
734 | 777 | ||
@@ -1835,9 +1878,11 @@ initvar(void) | |||
1835 | #if ENABLE_FEATURE_EDITING && ENABLE_FEATURE_EDITING_FANCY_PROMPT | 1878 | #if ENABLE_FEATURE_EDITING && ENABLE_FEATURE_EDITING_FANCY_PROMPT |
1836 | vps1.text = "PS1=\\w \\$ "; | 1879 | vps1.text = "PS1=\\w \\$ "; |
1837 | #else | 1880 | #else |
1881 | #ifndef __MINGW32__ | ||
1838 | if (!geteuid()) | 1882 | if (!geteuid()) |
1839 | vps1.text = "PS1=# "; | 1883 | vps1.text = "PS1=# "; |
1840 | #endif | 1884 | #endif |
1885 | #endif | ||
1841 | vp = varinit; | 1886 | vp = varinit; |
1842 | end = vp + sizeof(varinit) / sizeof(varinit[0]); | 1887 | end = vp + sizeof(varinit) / sizeof(varinit[0]); |
1843 | do { | 1888 | do { |
@@ -2244,6 +2289,7 @@ cdopt(void) | |||
2244 | * Update curdir (the name of the current directory) in response to a | 2289 | * Update curdir (the name of the current directory) in response to a |
2245 | * cd command. | 2290 | * cd command. |
2246 | */ | 2291 | */ |
2292 | #ifndef __MINGW32__ | ||
2247 | static const char * | 2293 | static const char * |
2248 | updatepwd(const char *dir) | 2294 | updatepwd(const char *dir) |
2249 | { | 2295 | { |
@@ -2301,6 +2347,7 @@ updatepwd(const char *dir) | |||
2301 | *new = 0; | 2347 | *new = 0; |
2302 | return stackblock(); | 2348 | return stackblock(); |
2303 | } | 2349 | } |
2350 | #endif | ||
2304 | 2351 | ||
2305 | /* | 2352 | /* |
2306 | * Find out what the current directory is. If we already know the current | 2353 | * Find out what the current directory is. If we already know the current |
@@ -3147,9 +3194,11 @@ static int job_warning; /* user was warned about stopped jobs */ | |||
3147 | static int jobctl; /* true if doing job control */ | 3194 | static int jobctl; /* true if doing job control */ |
3148 | #endif | 3195 | #endif |
3149 | 3196 | ||
3197 | #ifndef __MINGW32__ | ||
3150 | static struct job *makejob(union node *, int); | 3198 | static struct job *makejob(union node *, int); |
3151 | static int forkshell(struct job *, union node *, int); | 3199 | static int forkshell(struct job *, union node *, int); |
3152 | static int waitforjob(struct job *); | 3200 | static int waitforjob(struct job *); |
3201 | #endif | ||
3153 | 3202 | ||
3154 | #if ! JOBS | 3203 | #if ! JOBS |
3155 | #define setjobctl(on) /* do nothing */ | 3204 | #define setjobctl(on) /* do nothing */ |
@@ -3167,7 +3216,9 @@ setsignal(int signo) | |||
3167 | { | 3216 | { |
3168 | int action; | 3217 | int action; |
3169 | char *t, tsig; | 3218 | char *t, tsig; |
3219 | #ifndef __MINGW32__ | ||
3170 | struct sigaction act; | 3220 | struct sigaction act; |
3221 | #endif | ||
3171 | 3222 | ||
3172 | t = trap[signo]; | 3223 | t = trap[signo]; |
3173 | if (t == NULL) | 3224 | if (t == NULL) |
@@ -3182,11 +3233,13 @@ setsignal(int signo) | |||
3182 | if (iflag || minusc || sflag == 0) | 3233 | if (iflag || minusc || sflag == 0) |
3183 | action = S_CATCH; | 3234 | action = S_CATCH; |
3184 | break; | 3235 | break; |
3236 | #ifndef __MINGW32__ | ||
3185 | case SIGQUIT: | 3237 | case SIGQUIT: |
3186 | #if DEBUG | 3238 | #if DEBUG |
3187 | if (debug) | 3239 | if (debug) |
3188 | break; | 3240 | break; |
3189 | #endif | 3241 | #endif |
3242 | #endif | ||
3190 | /* FALLTHROUGH */ | 3243 | /* FALLTHROUGH */ |
3191 | case SIGTERM: | 3244 | case SIGTERM: |
3192 | if (iflag) | 3245 | if (iflag) |
@@ -3204,6 +3257,7 @@ setsignal(int signo) | |||
3204 | 3257 | ||
3205 | t = &sigmode[signo - 1]; | 3258 | t = &sigmode[signo - 1]; |
3206 | tsig = *t; | 3259 | tsig = *t; |
3260 | #ifndef __MINGW32__ | ||
3207 | if (tsig == 0) { | 3261 | if (tsig == 0) { |
3208 | /* | 3262 | /* |
3209 | * current setting unknown | 3263 | * current setting unknown |
@@ -3243,6 +3297,7 @@ setsignal(int signo) | |||
3243 | act.sa_flags = 0; | 3297 | act.sa_flags = 0; |
3244 | sigfillset(&act.sa_mask); | 3298 | sigfillset(&act.sa_mask); |
3245 | sigaction(signo, &act, 0); | 3299 | sigaction(signo, &act, 0); |
3300 | #endif | ||
3246 | } | 3301 | } |
3247 | 3302 | ||
3248 | /* mode flags for set_curjob */ | 3303 | /* mode flags for set_curjob */ |
@@ -3259,6 +3314,8 @@ setsignal(int signo) | |||
3259 | static int initialpgrp; | 3314 | static int initialpgrp; |
3260 | static int ttyfd = -1; | 3315 | static int ttyfd = -1; |
3261 | #endif | 3316 | #endif |
3317 | |||
3318 | #ifndef __MINGW32__ | ||
3262 | /* array of jobs */ | 3319 | /* array of jobs */ |
3263 | static struct job *jobtab; | 3320 | static struct job *jobtab; |
3264 | /* size of array */ | 3321 | /* size of array */ |
@@ -3315,8 +3372,9 @@ set_curjob(struct job *jp, unsigned mode) | |||
3315 | break; | 3372 | break; |
3316 | } | 3373 | } |
3317 | } | 3374 | } |
3375 | #endif | ||
3318 | 3376 | ||
3319 | #if JOBS || DEBUG | 3377 | #if JOBS || (DEBUG && !defined(__MINGW32__)) |
3320 | static int | 3378 | static int |
3321 | jobno(const struct job *jp) | 3379 | jobno(const struct job *jp) |
3322 | { | 3380 | { |
@@ -3324,6 +3382,7 @@ jobno(const struct job *jp) | |||
3324 | } | 3382 | } |
3325 | #endif | 3383 | #endif |
3326 | 3384 | ||
3385 | #ifndef __MINGW32__ | ||
3327 | /* | 3386 | /* |
3328 | * Convert a job name to a job structure. | 3387 | * Convert a job name to a job structure. |
3329 | */ | 3388 | */ |
@@ -3427,6 +3486,7 @@ freejob(struct job *jp) | |||
3427 | set_curjob(jp, CUR_DELETE); | 3486 | set_curjob(jp, CUR_DELETE); |
3428 | INT_ON; | 3487 | INT_ON; |
3429 | } | 3488 | } |
3489 | #endif | ||
3430 | 3490 | ||
3431 | #if JOBS | 3491 | #if JOBS |
3432 | static void | 3492 | static void |
@@ -3600,6 +3660,7 @@ fg_bgcmd(int argc, char **argv) | |||
3600 | } | 3660 | } |
3601 | #endif | 3661 | #endif |
3602 | 3662 | ||
3663 | #ifndef __MINGW32__ | ||
3603 | static int | 3664 | static int |
3604 | sprint_status(char *s, int status, int sigonly) | 3665 | sprint_status(char *s, int status, int sigonly) |
3605 | { | 3666 | { |
@@ -3768,6 +3829,7 @@ dowait(int block, struct job *job) | |||
3768 | } | 3829 | } |
3769 | return pid; | 3830 | return pid; |
3770 | } | 3831 | } |
3832 | #endif | ||
3771 | 3833 | ||
3772 | #if JOBS | 3834 | #if JOBS |
3773 | static void | 3835 | static void |
@@ -3885,6 +3947,7 @@ showjobs(FILE *out, int mode) | |||
3885 | } | 3947 | } |
3886 | #endif /* JOBS */ | 3948 | #endif /* JOBS */ |
3887 | 3949 | ||
3950 | #ifndef __MINGW32__ | ||
3888 | static int | 3951 | static int |
3889 | getstatus(struct job *job) | 3952 | getstatus(struct job *job) |
3890 | { | 3953 | { |
@@ -4058,6 +4121,7 @@ makejob(union node *node, int nprocs) | |||
4058 | jobno(jp))); | 4121 | jobno(jp))); |
4059 | return jp; | 4122 | return jp; |
4060 | } | 4123 | } |
4124 | #endif | ||
4061 | 4125 | ||
4062 | #if JOBS | 4126 | #if JOBS |
4063 | /* | 4127 | /* |
@@ -4341,6 +4405,7 @@ commandtext(union node *n) | |||
4341 | } | 4405 | } |
4342 | #endif /* JOBS */ | 4406 | #endif /* JOBS */ |
4343 | 4407 | ||
4408 | #ifndef __MINGW32__ | ||
4344 | /* | 4409 | /* |
4345 | * Fork off a subshell. If we are doing job control, give the subshell its | 4410 | * Fork off a subshell. If we are doing job control, give the subshell its |
4346 | * own process group. Jp is a job structure that the job is to be added to. | 4411 | * own process group. Jp is a job structure that the job is to be added to. |
@@ -4376,6 +4441,7 @@ clear_traps(void) | |||
4376 | } | 4441 | } |
4377 | } | 4442 | } |
4378 | } | 4443 | } |
4444 | |||
4379 | /* lives far away from here, needed for forkchild */ | 4445 | /* lives far away from here, needed for forkchild */ |
4380 | static void closescript(void); | 4446 | static void closescript(void); |
4381 | static void | 4447 | static void |
@@ -4554,6 +4620,7 @@ stoppedjobs(void) | |||
4554 | out: | 4620 | out: |
4555 | return retval; | 4621 | return retval; |
4556 | } | 4622 | } |
4623 | #endif | ||
4557 | 4624 | ||
4558 | 4625 | ||
4559 | /* ============ redir.c | 4626 | /* ============ redir.c |
@@ -4632,6 +4699,7 @@ noclobberopen(const char *fname) | |||
4632 | * the pipe without forking. | 4699 | * the pipe without forking. |
4633 | */ | 4700 | */ |
4634 | /* openhere needs this forward reference */ | 4701 | /* openhere needs this forward reference */ |
4702 | #ifndef __MINGW32__ | ||
4635 | static void expandhere(union node *arg, int fd); | 4703 | static void expandhere(union node *arg, int fd); |
4636 | static int | 4704 | static int |
4637 | openhere(union node *redir) | 4705 | openhere(union node *redir) |
@@ -4667,6 +4735,7 @@ openhere(union node *redir) | |||
4667 | close(pip[1]); | 4735 | close(pip[1]); |
4668 | return pip[0]; | 4736 | return pip[0]; |
4669 | } | 4737 | } |
4738 | #endif | ||
4670 | 4739 | ||
4671 | static int | 4740 | static int |
4672 | openredirect(union node *redir) | 4741 | openredirect(union node *redir) |
@@ -5171,7 +5240,9 @@ exptilde(char *startp, char *p, int flag) | |||
5171 | { | 5240 | { |
5172 | char c; | 5241 | char c; |
5173 | char *name; | 5242 | char *name; |
5243 | #ifndef __MINGW32__ | ||
5174 | struct passwd *pw; | 5244 | struct passwd *pw; |
5245 | #endif | ||
5175 | const char *home; | 5246 | const char *home; |
5176 | int quotes = flag & (EXP_FULL | EXP_CASE); | 5247 | int quotes = flag & (EXP_FULL | EXP_CASE); |
5177 | int startloc; | 5248 | int startloc; |
@@ -5198,10 +5269,14 @@ exptilde(char *startp, char *p, int flag) | |||
5198 | if (*name == '\0') { | 5269 | if (*name == '\0') { |
5199 | home = lookupvar(homestr); | 5270 | home = lookupvar(homestr); |
5200 | } else { | 5271 | } else { |
5272 | #ifdef __MINGW32__ | ||
5273 | goto lose; | ||
5274 | #else | ||
5201 | pw = getpwnam(name); | 5275 | pw = getpwnam(name); |
5202 | if (pw == NULL) | 5276 | if (pw == NULL) |
5203 | goto lose; | 5277 | goto lose; |
5204 | home = pw->pw_dir; | 5278 | home = pw->pw_dir; |
5279 | #endif | ||
5205 | } | 5280 | } |
5206 | if (!home || !*home) | 5281 | if (!home || !*home) |
5207 | goto lose; | 5282 | goto lose; |
@@ -7668,6 +7743,7 @@ expredir(union node *n) | |||
7668 | * of the shell, which make the last process in a pipeline the parent | 7743 | * of the shell, which make the last process in a pipeline the parent |
7669 | * of all the rest.) | 7744 | * of all the rest.) |
7670 | */ | 7745 | */ |
7746 | #ifndef __MINGW32__ | ||
7671 | static void | 7747 | static void |
7672 | evalpipe(union node *n, int flags) | 7748 | evalpipe(union node *n, int flags) |
7673 | { | 7749 | { |
@@ -7721,6 +7797,7 @@ evalpipe(union node *n, int flags) | |||
7721 | } | 7797 | } |
7722 | INT_ON; | 7798 | INT_ON; |
7723 | } | 7799 | } |
7800 | #endif | ||
7724 | 7801 | ||
7725 | /* | 7802 | /* |
7726 | * Controls whether the shell is interactive or not. | 7803 | * Controls whether the shell is interactive or not. |
@@ -7734,7 +7811,9 @@ setinteractive(int on) | |||
7734 | return; | 7811 | return; |
7735 | is_interactive = on; | 7812 | is_interactive = on; |
7736 | setsignal(SIGINT); | 7813 | setsignal(SIGINT); |
7814 | #ifndef __MINGW32__ | ||
7737 | setsignal(SIGQUIT); | 7815 | setsignal(SIGQUIT); |
7816 | #endif | ||
7738 | setsignal(SIGTERM); | 7817 | setsignal(SIGTERM); |
7739 | #if !ENABLE_FEATURE_SH_EXTRA_QUIET | 7818 | #if !ENABLE_FEATURE_SH_EXTRA_QUIET |
7740 | if (is_interactive > 1) { | 7819 | if (is_interactive > 1) { |
@@ -8157,7 +8236,9 @@ evalcommand(union node *cmd, int flags) | |||
8157 | int argc; | 8236 | int argc; |
8158 | const struct strlist *sp; | 8237 | const struct strlist *sp; |
8159 | struct cmdentry cmdentry; | 8238 | struct cmdentry cmdentry; |
8239 | #ifndef __MINGW32__ | ||
8160 | struct job *jp; | 8240 | struct job *jp; |
8241 | #endif | ||
8161 | char *lastarg; | 8242 | char *lastarg; |
8162 | const char *path; | 8243 | const char *path; |
8163 | int spclbltin; | 8244 | int spclbltin; |
@@ -8554,6 +8635,7 @@ preadfd(void) | |||
8554 | nr = safe_read(parsefile->fd, buf, BUFSIZ - 1); | 8635 | nr = safe_read(parsefile->fd, buf, BUFSIZ - 1); |
8555 | #endif | 8636 | #endif |
8556 | 8637 | ||
8638 | #ifndef __MINGW32__ | ||
8557 | if (nr < 0) { | 8639 | if (nr < 0) { |
8558 | if (parsefile->fd == 0 && errno == EWOULDBLOCK) { | 8640 | if (parsefile->fd == 0 && errno == EWOULDBLOCK) { |
8559 | int flags = fcntl(0, F_GETFL, 0); | 8641 | int flags = fcntl(0, F_GETFL, 0); |
@@ -8566,6 +8648,7 @@ preadfd(void) | |||
8566 | } | 8648 | } |
8567 | } | 8649 | } |
8568 | } | 8650 | } |
8651 | #endif | ||
8569 | return nr; | 8652 | return nr; |
8570 | } | 8653 | } |
8571 | 8654 | ||
@@ -8806,6 +8889,7 @@ popallfiles(void) | |||
8806 | popfile(); | 8889 | popfile(); |
8807 | } | 8890 | } |
8808 | 8891 | ||
8892 | #ifndef __MINGW32__ | ||
8809 | /* | 8893 | /* |
8810 | * Close the file(s) that the shell is reading commands from. Called | 8894 | * Close the file(s) that the shell is reading commands from. Called |
8811 | * after a fork is done. | 8895 | * after a fork is done. |
@@ -8819,6 +8903,7 @@ closescript(void) | |||
8819 | parsefile->fd = 0; | 8903 | parsefile->fd = 0; |
8820 | } | 8904 | } |
8821 | } | 8905 | } |
8906 | #endif | ||
8822 | 8907 | ||
8823 | /* | 8908 | /* |
8824 | * Like setinputfile, but takes an open file descriptor. Call this with | 8909 | * Like setinputfile, but takes an open file descriptor. Call this with |
@@ -8827,7 +8912,9 @@ closescript(void) | |||
8827 | static void | 8912 | static void |
8828 | setinputfd(int fd, int push) | 8913 | setinputfd(int fd, int push) |
8829 | { | 8914 | { |
8915 | #ifndef __MINGW32__ | ||
8830 | fcntl(fd, F_SETFD, FD_CLOEXEC); | 8916 | fcntl(fd, F_SETFD, FD_CLOEXEC); |
8917 | #endif | ||
8831 | if (push) { | 8918 | if (push) { |
8832 | pushfile(); | 8919 | pushfile(); |
8833 | parsefile->buf = 0; | 8920 | parsefile->buf = 0; |
@@ -11361,6 +11448,7 @@ unsetcmd(int argc, char **argv) | |||
11361 | 11448 | ||
11362 | /* setmode.c */ | 11449 | /* setmode.c */ |
11363 | 11450 | ||
11451 | #ifndef __MINGW32__ | ||
11364 | #include <sys/times.h> | 11452 | #include <sys/times.h> |
11365 | 11453 | ||
11366 | static const unsigned char timescmd_str[] = { | 11454 | static const unsigned char timescmd_str[] = { |
@@ -11393,6 +11481,7 @@ timescmd(int ac, char **av) | |||
11393 | 11481 | ||
11394 | return 0; | 11482 | return 0; |
11395 | } | 11483 | } |
11484 | #endif | ||
11396 | 11485 | ||
11397 | #if ENABLE_ASH_MATH_SUPPORT | 11486 | #if ENABLE_ASH_MATH_SUPPORT |
11398 | static arith_t | 11487 | static arith_t |
@@ -11708,6 +11797,7 @@ umaskcmd(int argc, char **argv) | |||
11708 | return 0; | 11797 | return 0; |
11709 | } | 11798 | } |
11710 | 11799 | ||
11800 | #ifndef __MINGW32__ | ||
11711 | /* | 11801 | /* |
11712 | * ulimit builtin | 11802 | * ulimit builtin |
11713 | * | 11803 | * |
@@ -11889,6 +11979,7 @@ ulimitcmd(int argc, char **argv) | |||
11889 | } | 11979 | } |
11890 | return 0; | 11980 | return 0; |
11891 | } | 11981 | } |
11982 | #endif | ||
11892 | 11983 | ||
11893 | 11984 | ||
11894 | /* ============ Math support */ | 11985 | /* ============ Math support */ |
@@ -12583,14 +12674,18 @@ init(void) | |||
12583 | basepf.nextc = basepf.buf = basebuf; | 12674 | basepf.nextc = basepf.buf = basebuf; |
12584 | 12675 | ||
12585 | /* from trap.c: */ | 12676 | /* from trap.c: */ |
12677 | #ifndef __MINGW32__ | ||
12586 | signal(SIGCHLD, SIG_DFL); | 12678 | signal(SIGCHLD, SIG_DFL); |
12679 | #endif | ||
12587 | 12680 | ||
12588 | /* from var.c: */ | 12681 | /* from var.c: */ |
12589 | { | 12682 | { |
12590 | char **envp; | 12683 | char **envp; |
12684 | #ifndef __MINGW32__ | ||
12591 | char ppid[sizeof(int)*3 + 1]; | 12685 | char ppid[sizeof(int)*3 + 1]; |
12592 | const char *p; | 12686 | const char *p; |
12593 | struct stat st1, st2; | 12687 | struct stat st1, st2; |
12688 | #endif | ||
12594 | 12689 | ||
12595 | initvar(); | 12690 | initvar(); |
12596 | for (envp = environ; envp && *envp; envp++) { | 12691 | for (envp = environ; envp && *envp; envp++) { |
@@ -12599,6 +12694,9 @@ init(void) | |||
12599 | } | 12694 | } |
12600 | } | 12695 | } |
12601 | 12696 | ||
12697 | #ifdef __MINGW32__ | ||
12698 | setpwd(NULL, 0); | ||
12699 | #else | ||
12602 | snprintf(ppid, sizeof(ppid), "%u", (unsigned) getppid()); | 12700 | snprintf(ppid, sizeof(ppid), "%u", (unsigned) getppid()); |
12603 | setvar("PPID", ppid, 0); | 12701 | setvar("PPID", ppid, 0); |
12604 | 12702 | ||
@@ -12608,6 +12706,7 @@ init(void) | |||
12608 | || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) | 12706 | || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) |
12609 | p = '\0'; | 12707 | p = '\0'; |
12610 | setpwd(p, 0); | 12708 | setpwd(p, 0); |
12709 | #endif | ||
12611 | } | 12710 | } |
12612 | } | 12711 | } |
12613 | 12712 | ||
@@ -12801,7 +12900,7 @@ int ash_main(int argc, char **argv) | |||
12801 | state2: | 12900 | state2: |
12802 | state = 3; | 12901 | state = 3; |
12803 | if ( | 12902 | if ( |
12804 | #ifndef linux | 12903 | #if !defined(linux) && !defined(__MINGW32__) |
12805 | getuid() == geteuid() && getgid() == getegid() && | 12904 | getuid() == geteuid() && getgid() == getegid() && |
12806 | #endif | 12905 | #endif |
12807 | iflag | 12906 | iflag |
@@ -12841,6 +12940,7 @@ int ash_main(int argc, char **argv) | |||
12841 | /* NOTREACHED */ | 12940 | /* NOTREACHED */ |
12842 | } | 12941 | } |
12843 | 12942 | ||
12943 | #if 0 | ||
12844 | #if DEBUG | 12944 | #if DEBUG |
12845 | const char *applet_name = "debug stuff usage"; | 12945 | const char *applet_name = "debug stuff usage"; |
12846 | int main(int argc, char **argv) | 12946 | int main(int argc, char **argv) |
@@ -12848,6 +12948,7 @@ int main(int argc, char **argv) | |||
12848 | return ash_main(argc, argv); | 12948 | return ash_main(argc, argv); |
12849 | } | 12949 | } |
12850 | #endif | 12950 | #endif |
12951 | #endif | ||
12851 | 12952 | ||
12852 | 12953 | ||
12853 | /*- | 12954 | /*- |