diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-08 21:02:42 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-08 21:02:42 +0100 |
commit | f8416dc6f64244223fbcb20fe504b7a9a764e698 (patch) | |
tree | 44c483d9a52a0b1126b4df97b68ec2307967fc86 /libbb/get_shell_name.c | |
parent | 681efe20d327e9e6774b174a617d66bbb9d21f48 (diff) | |
download | busybox-w32-f8416dc6f64244223fbcb20fe504b7a9a764e698.tar.gz busybox-w32-f8416dc6f64244223fbcb20fe504b7a9a764e698.tar.bz2 busybox-w32-f8416dc6f64244223fbcb20fe504b7a9a764e698.zip |
forgot to add libbb/get_shell_name.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/get_shell_name.c')
-rw-r--r-- | libbb/get_shell_name.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libbb/get_shell_name.c b/libbb/get_shell_name.c new file mode 100644 index 000000000..c930afd94 --- /dev/null +++ b/libbb/get_shell_name.c | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * Copyright 2011, Denys Vlasenko | ||
3 | * | ||
4 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
5 | */ | ||
6 | |||
7 | //kbuild:lib-y += get_shell_name.o | ||
8 | |||
9 | #include "libbb.h" | ||
10 | |||
11 | const char *get_shell_name(void) | ||
12 | { | ||
13 | struct passwd *pw; | ||
14 | char *shell; | ||
15 | |||
16 | shell = getenv("SHELL"); | ||
17 | if (shell && shell[0]) | ||
18 | return shell; | ||
19 | |||
20 | pw = getpwuid(getuid()); | ||
21 | if (pw && pw->pw_shell && pw->pw_shell[0]) | ||
22 | return pw->pw_shell; | ||
23 | |||
24 | return DEFAULT_SHELL; | ||
25 | } | ||