Closed allisio closed 4 years ago
Thanks for the the contribution, that seems like a better way to do it. However, could you change it to
strncpy(shell, strrchr(getenv("SHELL"), '/') + 1, BUF_SIZE);
I realize that in all likelihood the name of your shell will never be more than 150 characters long, but this also ensures that the string is null terminated I believe. Plus I'd prefer to keep it consistent with the rest of the code, where I always use strncpy
I'll make the commit myself
Be advised that strncpy()
doesn't guarantee null-termination.
get_shell()
currently assumes the relevant environment variable will be of the form/bin/%s
, but this isn't always the case. This patch instead assumes that everything after the last/
is the name of the user's shell.