c++ - Better way to determine which shell is being used at runtime (Windows)? -
i have function clears terminal screen. it's supposed work on windows , *nix based os. if function detects caller's os windows, check see if caller using cmd.exe
or else (git-bash
or cygwin
).
is there better way this? don't fact need rely on home variable.
compiler: g++
#include <cstdlib> void clearscreen() { #ifdef _win32 if (std::getenv("home")) // git-bash & cygwin home var called home std::system("clear"); // cmd's home var called homepath else std::system("cls"); #else // assume posix std::system("clear"); #endif }
note: function has been tested in cmd.exe
, git-bash
, , wsl
. has not been tested in cygwin
.
Comments
Post a Comment