3
0

get_shell_name.c 430 B

12345678910111213141516171819202122232425
  1. /*
  2. * Copyright 2011, Denys Vlasenko
  3. *
  4. * Licensed under GPLv2, see file LICENSE in this source tree.
  5. */
  6. //kbuild:lib-y += get_shell_name.o
  7. #include "libbb.h"
  8. const char* FAST_FUNC get_shell_name(void)
  9. {
  10. struct passwd *pw;
  11. char *shell;
  12. shell = getenv("SHELL");
  13. if (shell && shell[0])
  14. return shell;
  15. pw = getpwuid(getuid());
  16. if (pw && pw->pw_shell && pw->pw_shell[0])
  17. return pw->pw_shell;
  18. return DEFAULT_SHELL;
  19. }