MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / shellenv

Function shellenv

src/core/msystem.cpp:595–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593static const char *shellenv(void)
594#else
595static 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

Callers 1

msystem.cppFile · 0.85

Calls 1

initenvFunction · 0.85

Tested by

no test coverage detected