BCM WL 6.30.102.9 (r366174)
[tomato.git] / release / src / router / busybox / libbb / get_shell_name.c
blob5aebe9cdccec81038eb4cd5a7d2e212735cdef45
1 /*
2 * Copyright 2011, Denys Vlasenko
4 * Licensed under GPLv2, see file LICENSE in this source tree.
5 */
7 //kbuild:lib-y += get_shell_name.o
9 #include "libbb.h"
11 const char* FAST_FUNC get_shell_name(void)
13 struct passwd *pw;
14 char *shell;
16 shell = getenv("SHELL");
17 if (shell && shell[0])
18 return shell;
20 pw = getpwuid(getuid());
21 if (pw && pw->pw_shell && pw->pw_shell[0])
22 return pw->pw_shell;
24 return DEFAULT_SHELL;