aboutsummaryrefslogtreecommitdiff
path: root/libbb/get_shell_name.c
blob: 5aebe9cdccec81038eb4cd5a7d2e212735cdef45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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* FAST_FUNC 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;
}