RE: [gtk+-2.6.7] configure problem



Xu Qiang wrote:
> KC wrote:
>> I don't know any command which can report your login shell for you,
>> but you can easily write one yourself by C language, just call
>> getusershell() as following: 
>> 
>> 
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <unistd.h>
>> 
>> int main (int argc, char *argv[])
>> {
>>         printf("%s\n", getusershell());
>>         exit(0);
>> }
> 
> But this test output "/bin/sh". If it is C shell, it should output
> "/bin/csh", right? What shell is this? 

Through "man getusershell", I got to know that this function just reads the next line of the file "/etc/shells" (opening the file if necessary). 
The content of that file in my machine is:
-----------------------------------------------------------------
# $FreeBSD: src/etc/shells,v 1.5 2000/04/27 21:58:46 ache Exp $
#
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/sh
/bin/csh
/bin/tcsh
-----------------------------------------------------------------

And I modified your code as: 
-----------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main (int argc, char *argv[])
{
        printf("%s\n", getusershell());
        printf("%s\n", getusershell());
        printf("%s\n", getusershell());
        exit(0);
}
-----------------------------------------------------------------

The output is just the 3 lines of shell names in /etc/shells. So I gather that it can't be used to determine the current shell one is using. 

But your advice of looking into the file /etc/passwd is good and useful. 

Thank you very much, 

Regards,
Xu Qiang





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]