exec_shell: prevent basename from modifying env

Fix warning:
passing 'const char *' to parameter of type 'char *' discards
qualifiers [-Wincompatible-pointer-types-discards-qualifiers]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
This commit is contained in:
Ruediger Meier 2016-02-11 03:45:11 +01:00
parent 4a04d7f3d6
commit 7f79adb342

View file

@ -32,12 +32,15 @@
void exec_shell(void) void exec_shell(void)
{ {
const char *shell = getenv("SHELL"), *shell_basename; const char *shell = getenv("SHELL");
char *shellc = xstrdup(shell);
const char *shell_basename;
char *arg0; char *arg0;
if (!shell) if (!shell)
shell = DEFAULT_SHELL; shell = DEFAULT_SHELL;
shell_basename = basename(shell); shell_basename = basename(shellc);
arg0 = xmalloc(strlen(shell_basename) + 2); arg0 = xmalloc(strlen(shell_basename) + 2);
arg0[0] = '-'; arg0[0] = '-';
strcpy(arg0 + 1, shell_basename); strcpy(arg0 + 1, shell_basename);