int bCached = 1;\r
t_sysFInfo info;\r
\r
- //Command_Clear(0, NULL);\r
+ Command_Clear(0, NULL);\r
\r
{\r
char *tmp = getenv("CWD");\r
if(saArgs[0]) free(saArgs);\r
if(!bCached) free(sCommandStr);\r
bCached = 0;\r
- write(_stdout, 1, "\n");\r
write(_stdout, strlen(gsCurrentDirectory), gsCurrentDirectory);\r
write(_stdout, 3, "$ ");\r
\r
}\r
// Load new executable\r
pid = clone(CLONE_VM, 0);\r
+ printf("pid = %i\n", pid);\r
if(pid == 0) execve(gsTmpBuffer, &saArgs[1], envp);\r
if(pid <= 0) {\r
Print("Unablt to create process: `");Print(gsTmpBuffer);Print("'\n"); // Error Message
\r
// Preset Variables\r
ret = malloc( space+1 );\r
+ if(!ret) return NULL;\r
len = 0;\r
pos = 0;\r
\r
do {\r
read(_stdin, 1, &ch); // Read Character from stdin (read is a blocking call)\r
// Ignore control characters\r
- if(ch < 0) continue;\r
+ if(ch == '\x1B') {\r
+ read(_stdin, 1, &ch); // Read control character\r
+ switch(ch)\r
+ {\r
+ case 'D': if(pos) pos--; break;\r
+ case 'C': if(pos<len) pos++; break;\r
+ case '[':\r
+ read(_stdin, 1, &ch); // Read control character\r
+ switch(ch)\r
+ {\r
+ case 'D': if(pos) pos--; break;\r
+ case 'C': if(pos<len) pos++; break;\r
+ }\r
+ }\r
+ continue;\r
+ }\r
// Backspace\r
if(ch == '\b') {\r
if(len <= 0) continue; // Protect against underflows\r
free(gsCurrentDirectory);\r
gsCurrentDirectory = malloc(strlen(tmpPath)+1);\r
strcpy(gsCurrentDirectory, tmpPath);\r
+ \r
+ // Register change with kernel\r
+ chdir( gsCurrentDirectory );\r
}\r
\r
/**\r
// Get File Stats\r
finfo(fp, &info, 0);\r
\r
- //Print Mode\r
- //#if 0\r
+ if(info.flags & FILEFLAG_DIRECTORY)\r
+ write(_stdout, 1, "d");\r
+ else\r
+ write(_stdout, 1, "-");\r
+ \r
+ // Print Mode\r
acl.group = 0; acl.id = info.uid;\r
_SysGetACL(fp, &acl);\r
if(acl.perms & 1) modeStr[0] = 'r'; else modeStr[0] = '-';\r
if(acl.perms & 1) modeStr[7] = 'w'; else modeStr[7] = '-';\r
if(acl.perms & 1) modeStr[8] = 'x'; else modeStr[8] = '-';\r
write(_stdout, 10, modeStr);\r
- //#endif\r
close(fp);\r
\r
// Colour Code\r
if(info.flags & FILEFLAG_DIRECTORY) // Directory: Green\r
write(_stdout, 6, "\x1B[32m");\r
- else\r
- write(_stdout, 6, "\x1B[37m"); // Default: White\r
+ // Default: White\r
+ \r
// Print Name\r
write(_stdout, strlen(fileName), fileName);\r
+ \r
// Print slash if applicable\r
if(info.flags & FILEFLAG_DIRECTORY)\r
write(_stdout, 1, "/");\r
// Revert Colour\r
write(_stdout, 6, "\x1B[37m");\r
\r
- // Put Size\r
- printf("\n", info.size);\r
- \r
- //write(_stdout, 1, "\n");\r
+ // Newline!\r
+ write(_stdout, 1, "\n");\r
}\r
// Close Directory\r
close(dp);\r