MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / main

Function main

Applications/LSh/main.cpp:219–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219int main(){
220 printf("Lemon SHell\n");
221
222 if(const char* h = getenv("HOME"); h){
223 chdir(h);
224 }
225
226 getcwd(currentDir, PATH_MAX);
227 tcgetattr(STDOUT_FILENO, &execAttributes);
228 readAttributes = execAttributes;
229 readAttributes.c_lflag &= ~(ICANON | ECHO); // Disable canonical mode and echo when reading user input
230
231 builtins.push_back(builtinPwd);
232 builtins.push_back(builtinCd);
233 builtins.push_back(builtinExport);
234 builtins.push_back(builtinClear);
235
236 std::string pathEnv = getenv("PATH");
237 std::string temp;
238 for(char c : pathEnv){
239 if(c == ':' && temp.length()){
240 path.push_back(temp);
241 temp.clear();
242 } else {
243 temp += c;
244 }
245 }
246 if(temp.length()){
247 path.push_back(temp);
248 temp.clear();
249 }
250
251 fflush(stdin);
252
253 for(;;) {
254 printf("\n\e[33mLemon \e[91m%s\e[m$ ", currentDir);
255 fflush(stdout);
256
257 ReadLine();
258 ParseLine();
259 }
260}

Callers

nothing calls this directly

Calls 4

ReadLineFunction · 0.85
ParseLineFunction · 0.85
lengthMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected