MCPcopy Create free account
hub / github.com/SpartanJ/eepp / getShellEnv

Function getShellEnv

src/tools/ecode/ecode.cpp:4219–4242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4217}
4218
4219static std::string getShellEnv( const std::string& env, const std::string& defShell = "" ) {
4220 std::string shell = defShell.empty() ? Sys::which( getDefaultShell() ) : defShell;
4221 Process process;
4222 if ( process.create( shell, "-l -c env", Process::getDefaultOptions() ) ) {
4223 size_t envLen = env.size();
4224 std::string buf( 32 * 1024, '\0' );
4225 process.readAllStdOut( buf );
4226 auto pathPos = buf.find( "\n" + env + "=" );
4227 bool startsWithPath = false;
4228 if ( pathPos == std::string::npos && buf.substr( 0, envLen + 1 ) == env + "=" )
4229 startsWithPath = true;
4230 if ( pathPos != std::string::npos || startsWithPath ) {
4231 pathPos += startsWithPath ? envLen + 1 : envLen + 2; // Remove \n + env + "="
4232 auto endPathPos = buf.find_first_of( "\r\n", pathPos );
4233 if ( endPathPos != std::string::npos ) {
4234 size_t len = endPathPos - pathPos;
4235 return buf.substr( pathPos, len );
4236 } else {
4237 return buf.substr( pathPos );
4238 }
4239 }
4240 }
4241 return "";
4242}
4243#endif
4244
4245FontTrueType* App::loadFont( const std::string& name, std::string fontPath,

Callers 1

initMethod · 0.85

Calls 9

getDefaultShellFunction · 0.85
getDefaultOptionsFunction · 0.85
readAllStdOutMethod · 0.80
substrMethod · 0.80
find_first_ofMethod · 0.80
emptyMethod · 0.45
createMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected