aboutsummaryrefslogtreecommitdiff
path: root/libbb/get_shell_name.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-03-22 13:56:39 +0000
committerRon Yorston <rmy@pobox.com>2012-03-22 13:56:39 +0000
commit811c449748d5bd0505f8510e5582892f94ac0cda (patch)
tree2640249cb2a9605c7cd59467b9861b205e9bcc8a /libbb/get_shell_name.c
parentc0d4367d6b581eb5989c02815880cf0fa2851ae8 (diff)
parent19311bfa7b8e8c6effa9c375de9b0eb4338bee12 (diff)
downloadbusybox-w32-811c449748d5bd0505f8510e5582892f94ac0cda.tar.gz
busybox-w32-811c449748d5bd0505f8510e5582892f94ac0cda.tar.bz2
busybox-w32-811c449748d5bd0505f8510e5582892f94ac0cda.zip
Merge commit '19311bfa7b8e8c6effa9c375de9b0eb4338bee12' into merge
Conflicts: coreutils/ls.c shell/ash.c
Diffstat (limited to 'libbb/get_shell_name.c')
-rw-r--r--libbb/get_shell_name.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libbb/get_shell_name.c b/libbb/get_shell_name.c
new file mode 100644
index 000000000..d196d293d
--- /dev/null
+++ b/libbb/get_shell_name.c
@@ -0,0 +1,27 @@
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
11const 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#if !ENABLE_PLATFORM_MINGW32
21 pw = getpwuid(getuid());
22 if (pw && pw->pw_shell && pw->pw_shell[0])
23 return pw->pw_shell;
24#endif
25
26 return DEFAULT_SHELL;
27}