forked from KolibriOS/kolibrios
SHELL 0.8.2
- big refactoring, now uses libc.obj - added kfetch command git-svn-id: svn://kolibrios.org@8827 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -1,74 +1,54 @@
|
||||
|
||||
/// ===========================================================
|
||||
int executable_run(char cmd[], char args[]) {
|
||||
char exec[FILENAME_MAX];
|
||||
int result;
|
||||
|
||||
int executable_run(char cmd[], char args[])
|
||||
{
|
||||
if ( '/' == cmd[0]) // if path is absolute
|
||||
{
|
||||
strcpy(exec, cmd);
|
||||
if (!file_check(exec) ) // check file existense
|
||||
{
|
||||
file_not_found(cmd);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
strcpy(exec, cur_dir); // check file in current directory
|
||||
if (exec[strlen(exec)-1] != '/')
|
||||
strcat(exec, "/"); // add slash
|
||||
strcat(exec, cmd);
|
||||
|
||||
if ( !file_check(exec) ) // check file existense
|
||||
{
|
||||
strcpy(exec, "/rd/1/"); // check file on virtual disk
|
||||
strcat(exec, cmd);
|
||||
if ( !file_check(exec) ) // check file existense
|
||||
{
|
||||
file_not_found(cmd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char exec[FILENAME_MAX];
|
||||
int result;
|
||||
// if file exists:
|
||||
|
||||
if ( '/' == cmd[0]) // if path is absolute
|
||||
{
|
||||
strcpy(exec, cmd);
|
||||
if (!file_check(exec) ) // check file existense
|
||||
{
|
||||
file_not_found(cmd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(exec, cur_dir); // check file in current directory
|
||||
if (exec[strlen(exec)-1] != '/')
|
||||
strcat(exec, "/"); // add slash
|
||||
strcat(exec, cmd);
|
||||
|
||||
if ( !file_check(exec) ) // check file existense
|
||||
{
|
||||
strcpy(exec, "/rd/1/"); // check file on virtual disk
|
||||
strcat(exec, cmd);
|
||||
if ( !file_check(exec) ) // check file existense
|
||||
{
|
||||
file_not_found(cmd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if file exists:
|
||||
|
||||
// try to run as a program
|
||||
result = program_run(exec, args);
|
||||
if (result > 0)
|
||||
{
|
||||
if ( !program_console(result) )
|
||||
{
|
||||
LAST_PID = result;
|
||||
#if LANG_ENG
|
||||
printf (" '%s' started. PID = %d\n\r", cmd, result);
|
||||
#elif LANG_RUS
|
||||
printf (" '%s' § ¯ãé¥. PID = %d\n\r", cmd, result);
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( script_check(exec) ) // if file is a valid script
|
||||
{
|
||||
return script_run(exec, args);
|
||||
} else
|
||||
{
|
||||
#if LANG_ENG
|
||||
printf ("Error in '%s' : script must start with #SHS line\n\r", cmd);
|
||||
#elif LANG_RUS
|
||||
printf ("Žè¨¡ª ¢ '%s' : áªà¨¯â ¤®«¦¥ ç¨ âìáï á® áâà®çª¨ #SHS\n\r", cmd);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
// try to run as a program
|
||||
result = program_run(exec, args);
|
||||
if (result > 0) {
|
||||
if ( !program_console(result) ) {
|
||||
LAST_PID = result;
|
||||
printf (EXEC_STARTED_FMT, cmd, result);
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
if ( script_check(exec) ) // if file is a valid script
|
||||
{
|
||||
return script_run(exec, args);
|
||||
} else
|
||||
{
|
||||
printf (EXEC_SCRIPT_ERROR_FMT, cmd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// ===========================================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user