kolibrios/programs/system/shell/modules/module_executable.c

70 lines
1.3 KiB
C
Raw Normal View History

/// ===========================================================
int executable_run(char cmd[], char args[])
{
char exec[FILENAME_MAX];
int result;
if ( '/' == cmd[0]) // <20><20><><EFBFBD><EFBFBD> <20><><EFBFBD><E1AEAB><EFBFBD><EFBFBD><EFBFBD>
{
strcpy(exec, cmd);
if ( !file_check(exec) ) // <20><EFBFBD><E0AEA2><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A2AE><EFBFBD><EFBFBD><EFBFBD><><E4A0A9>
{
file_not_found(cmd);
return FALSE;
}
}
else
{
strcpy(exec, cur_dir); // <20><EFBFBD><E0AEA2>塞 䠩<> <20><><20><><EFBFBD><E2A0AB><EFBFBD>
if (exec[strlen(exec)-1] != '/')
strcat(exec, "/"); // add slash
strcat(exec, cmd);
if ( !file_check(exec) ) // <20><EFBFBD><E0AEA2><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A2AE><EFBFBD><EFBFBD><EFBFBD><><E4A0A9>
{
strcpy(exec, "/rd/1/"); // <20><EFBFBD><E0AEA2>塞 䠩<> <20><> <20><><EFBFBD><EFBFBD>㠫쭮<E3A0AB> <20><>
strcat(exec, cmd);
if ( !file_check(exec) ) // <20><EFBFBD><E0AEA2><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A2AE><EFBFBD><EFBFBD><EFBFBD><><E4A0A9>
{
file_not_found(cmd);
return FALSE;
}
}
}
if ( script_check(exec) )
return script_run(exec, args);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ணࠬ<E0AEA3><E0A0AC> */
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' <20><><EFBFBD><EFBFBD>饭. PID = %d\n\r", cmd, result);
#endif
}
return TRUE;
}
else
{
file_not_found(cmd);
return FALSE;
}
}
/// ===========================================================