From: Denys Vlasenko Date: Tue, 8 Mar 2011 20:02:42 +0000 (+0100) Subject: forgot to add libbb/get_shell_name.c X-Git-Tag: 1_19_0~234 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8416dc6f64244223fbcb20fe504b7a9a764e698;p=platform%2Fupstream%2Fbusybox.git forgot to add libbb/get_shell_name.c Signed-off-by: Denys Vlasenko --- diff --git a/libbb/get_shell_name.c b/libbb/get_shell_name.c new file mode 100644 index 0000000..c930afd --- /dev/null +++ b/libbb/get_shell_name.c @@ -0,0 +1,25 @@ +/* + * Copyright 2011, Denys Vlasenko + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ + +//kbuild:lib-y += get_shell_name.o + +#include "libbb.h" + +const char *get_shell_name(void) +{ + struct passwd *pw; + char *shell; + + shell = getenv("SHELL"); + if (shell && shell[0]) + return shell; + + pw = getpwuid(getuid()); + if (pw && pw->pw_shell && pw->pw_shell[0]) + return pw->pw_shell; + + return DEFAULT_SHELL; +}