Replacement su for SCO Unix

Eamonn McManus emcmanus at cs.tcd.ie
Wed Oct 3 07:06:12 AEST 1990


ott at guug.guug.de (Joachim Ott Munich-Germany) writes:
>>    const char *user = "root", *shell = NULL;
> ...
>>    su(pwd, login, shell ? shell : pwd->pw_shell, argv + i - 1);
>...
>'shell ?' means
>'shell != 0' and *not* 'shell != NULL'. You should not rely on
>NULL being the same as 0. Try the line with '(shell != NULL) ?',
>the warning should be gone.

The code as it stands is correct.  The reason the Microsoft compiler
complains is not because of the implicit comparison against 0 but
because one of the ?: branches has type `const char *' and the other
type `char *'.  It should instead promote `const char *' to `char *'.
--
Eamonn McManus <emcmanus at cs.tcd.ie>
	Fingers are for fuguing.



More information about the Comp.unix.sysv386 mailing list