ss7m / paleofetch

neofetch, but written in C
MIT License
167 stars 49 forks source link

Make get_shell() handle shells that aren't in /bin #2

Closed allisio closed 4 years ago

allisio commented 4 years ago

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.

ss7m commented 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

ss7m commented 4 years ago

I'll make the commit myself

allisio commented 4 years ago

Be advised that strncpy() doesn't guarantee null-termination.