paleofetch

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit d8b32d25dd0655c8a3ffc86e6802eec3ce99fd26
parent 38253f89c61aab49d21ca13c8292fd8ce4d9d9e0
Author: sam-barr <samfbarr@outlook.com>
Date:   Thu, 23 Apr 2020 09:24:17 -0500

fixed bug when $SHELL=""

Diffstat:
Mpaleofetch.c | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/paleofetch.c b/paleofetch.c @@ -224,7 +224,14 @@ char *get_packages() { char *get_shell() { char *shell = malloc(BUF_SIZE); - strncpy(shell, strrchr(getenv("SHELL"), '/') + 1, BUF_SIZE); + char *shell_path = getenv("SHELL"); + char *shell_name = strrchr(getenv("SHELL"), '/'); + + if(shell_name == NULL) /* if $SHELL doesn't have a '/' */ + strncpy(shell, shell_path, BUF_SIZE); /* copy the whole thing over */ + else + strncpy(shell, shell_name + 1, BUF_SIZE); /* o/w copy past the last '/' */ + return shell; }