char *guess_shell(void) {
	const char *shell;
	char *retval;

	shell = env_get("SHELL");
	if (shell) {
		invalid_filename(shell, 0); // no globbing
		if (access(shell, X_OK) == 0 && !is_dir(shell) && strstr(shell, "..") == NULL &&
		    strcmp(gnu_basename(shell), "firejail") != 0)
			goto found;
	}

	// shells in order of preference
	static const char * const shells[] = {"/bin/bash", "/bin/csh", "/usr/bin/zsh", "/bin/sh", "/bin/ash", NULL };

	int i = 0;
	while (shells[i] != NULL) {
		// access call checks as real UID/GID, not as effective UID/GID
		if (access(shells[i], X_OK) == 0) {
			shell = shells[i];
			goto found;
		}
		i++;
	}

	return NULL;

 found:
	retval = strdup(shell);
	if (!retval)
		errExit("strdup");
	return retval;
}
char *guess_shell(void) {
	const char *shell;
	char *retval;

	shell = env_get("SHELL");
	if (shell) {
		invalid_filename(shell, 0);  
		if (access(shell, X_OK) == 0 && !is_dir(shell) && strstr(shell, "..") == NULL &&
		    strcmp(gnu_basename(shell), "firejail") != 0)
			goto found;
	}

	 
	static const char * const shells[] = {"/bin/bash", "/bin/csh", "/usr/bin/zsh", "/bin/sh", "/bin/ash", NULL };

	int i = 0;
	while (shells[i] != NULL) {
		 
		if (access(shells[i], X_OK) == 0) {
			shell = shells[i];
			goto found;
		}
		i++;
	}

	return NULL;

 found:
	retval = strdup(shell);
	if (!retval)
		errExit("strdup");
	return retval;
}