| 593 | static const char *shellenv(void) |
| 594 | #else |
| 595 | static const char *shellenv() |
| 596 | #endif |
| 597 | { |
| 598 | register int i; /* counter in a for loop */ |
| 599 | register const char *shptr; /* points to shell name */ |
| 600 | |
| 601 | /* |
| 602 | * error check; should never happen |
| 603 | */ |
| 604 | if (envp == NULL && (i = initenv()) != SE_NONE) |
| 605 | return(NULL); |
| 606 | |
| 607 | /* |
| 608 | * get the shell environment variable |
| 609 | */ |
| 610 | for(i = 0; envp[i] != NULL; i++) |
| 611 | if (strncmp(envp[i], "SHELL=", strlen("SHELL=")) == 0) |
| 612 | break; |
| 613 | /* |
| 614 | * not defined; use the default shell |
| 615 | */ |
| 616 | if (envp[i] == NULL) |
| 617 | shptr = NOSHELL; |
| 618 | else |
| 619 | shptr = strchr(envp[i], '=') + 1; |
| 620 | return(shptr); |
| 621 | } |
| 622 | |
| 623 | /* |
| 624 | * like system but A LOT safer |