Now for incorrect scripts (which doesnt start with #SHS) shell says that they are incorrect, not "File not found". Also, translated comments from russian to english in two files.

git-svn-id: svn://kolibrios.org@7792 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Rustem Gimadutdinov (rgimad) 2020-04-14 22:21:16 +00:00
parent abbaaa2ff2
commit b76d44d868
4 changed files with 127 additions and 122 deletions

View File

@ -1,5 +1,5 @@
#define SHELL_VERSION "0.7.8"
#define SHELL_VERSION "0.7.8a"
extern char PATH[256];
extern char PARAM[256];

View File

@ -7,29 +7,27 @@ int executable_run(char cmd[], char args[])
char exec[FILENAME_MAX];
int result;
if ( '/' == cmd[0]) // ¥á«¨ ¯ãâì  ¡á®«îâ­ë©
if ( '/' == cmd[0]) // if path is absolute
{
strcpy(exec, cmd);
if ( !file_check(exec) ) // ¯à®¢¥à塞 áãé¥á⢮¢ ­¨¥ ä ©« 
if (!file_check(exec) ) // check file existense
{
file_not_found(cmd);
return FALSE;
}
}
else
{
strcpy(exec, cur_dir); // ¯à®¢¥à塞 ä ©« ¢ ⥪ã饬 ª â «®£¥
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) ) // ¯à®¢¥à塞 áãé¥á⢮¢ ­¨¥ ä ©« 
if ( !file_check(exec) ) // check file existense
{
strcpy(exec, "/rd/1/"); // ¯à®¢¥à塞 ä ©« ­  ¢¨àâã «ì­®¬ ¤¨áª¥
strcpy(exec, "/rd/1/"); // check file on virtual disk
strcat(exec, cmd);
if ( !file_check(exec) ) // ¯à®¢¥à塞 áãé¥á⢮¢ ­¨¥ ä ©« 
if ( !file_check(exec) ) // check file existense
{
file_not_found(cmd);
return FALSE;
@ -37,15 +35,12 @@ else
}
}
// if file exists:
if ( script_check(exec) )
return script_run(exec, args);
/* § ¯ã᪠¯à®£à ¬¬ë */
// try to run as a program
result = program_run(exec, args);
if (result > 0)
{
if ( !program_console(result) )
{
LAST_PID = result;
@ -59,9 +54,19 @@ if (result > 0)
}
else
{
file_not_found(cmd);
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;
}
}
}

View File

@ -10,14 +10,14 @@ char buf[4];
k70.p00 = 0;
k70.p04 = 0;
//k70.p08 = 0;
k70.p12 = 4; // читать 4 байта
k70.p12 = 4; // read 4 bytes
k70.p16 = (unsigned) buf;
k70.p20 = 0;
k70.p21 = file;
kol_file_70(&k70);
if ( !strcmp(buf, script_sign) )
if ( !strcmp(buf, script_sign) ) // if we found the script signature
return TRUE;
else
return FALSE;
@ -32,7 +32,7 @@ kol_struct70 k70;
kol_struct_BDVK bdvk;
unsigned result, i;
unsigned long long filesize, pos;
char *buf; //буфер, куда копируется скрипт
char *buf; // buffer, where script is copied
k70.p00 = 5;
k70.p04 = k70.p12 = 0;
@ -41,11 +41,11 @@ k70.p16 = (unsigned) &bdvk;
k70.p20 = 0;
k70.p21 = exec;
result = kol_file_70(&k70); // получаем информацию о файле
result = kol_file_70(&k70); // get file info
if ( 0 != result )
return FALSE;
filesize = bdvk.p32; // получаем размер файла
filesize = bdvk.p32; // get file size
buf = malloc(filesize+256); // may fail for over 4Gb file, but impossible case
if (NULL == buf)
@ -61,7 +61,7 @@ k70.p16 = (unsigned) buf;
k70.p20 = 0;
k70.p21 = exec;
result = kol_file_70(&k70); // считываем файл в буфер
result = kol_file_70(&k70); // read file to the buffer
if ( 0 != result )
{
free(buf);
@ -70,13 +70,13 @@ if ( 0 != result )
pos = 0;
for (;;) // обработка скрипта
for (;;) // script processing
{
if (pos > filesize)
break;
for (i=0;;i++) // считывание строки
for (i=0;;i++) // reading a string
{
if ((0x0A == buf[pos])||(0x0D == buf[pos])||(0 == buf[pos]))
{
@ -88,10 +88,10 @@ for (;;) //
pos++;
}
if ( 0 == strlen(CMD) ) // пустая строка
if ( 0 == strlen(CMD) ) // empty string
continue;
if ('#' == CMD[0]) // комментарий
if ('#' == CMD[0]) // comment
continue;
command_execute();