Skip to content
Advertisement

Linux C++ Detect user shell (csh,bash,etc)

I have a C++ application that needs to make shell specific commands using system calls. Is there a way to detect which shell the user is running? (Csh/Bash/etc).

Thanks


Elaborate

I’m trying to work with some code that forks off via system a rsh call that has a sequence of commands that are using setenv which doesnt work in bash. I want to detect whether the system is csh or bash and rewrite the calls accordingly.

Advertisement

Answer

Dont know if this will be of any use

JavaScript

Will output something similar to

JavaScript

Getenv returns a c-string with the environment variables value.

Link:http://www.cplusplus.com/reference/cstdlib/getenv/

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement