diff --git a/programs/system/shell/globals.h b/programs/system/shell/globals.h index 8881564826..c878bd22e0 100644 --- a/programs/system/shell/globals.h +++ b/programs/system/shell/globals.h @@ -1,5 +1,5 @@ -#define SHELL_VERSION "0.6.3" +#define SHELL_VERSION "0.6.4" extern char PATH[256]; extern char PARAM[256]; diff --git a/programs/system/shell/shell.c b/programs/system/shell/shell.c index 9534fc7e7b..785e3f7ff5 100644 --- a/programs/system/shell/shell.c +++ b/programs/system/shell/shell.c @@ -128,10 +128,16 @@ con_set_cursor_height(con_get_font_height()-1); ALIASES = malloc(128*1024); -if (strlen(PARAM) > 0) +if (PARAM[0] == 0) strcpy(CMD, ".shell"); +else +{ + if (PARAM[0] == '/') + { + strcpy(cur_dir, PARAM); + *strrchr(cur_dir, '/')=0; + } strcpy(CMD, PARAM); -else - strcpy(CMD, ".shell"); +} command_execute(); diff --git a/programs/system/shell/system/string.c b/programs/system/shell/system/string.c index 5825f476bd..e45dad4262 100644 --- a/programs/system/shell/system/string.c +++ b/programs/system/shell/system/string.c @@ -123,6 +123,21 @@ char* strchr(const char* string, int c) } +char* strrchr(const char* string, int c) +{ + int last_found; + while (*string) + { + if (*string==c) + { + last_found = string; + } + string++; + } + return (char*)last_found; +} + + void _itoa(int i, char *s) { diff --git a/programs/system/shell/system/string.h b/programs/system/shell/system/string.h index 14b271a0f9..2ca5916ef9 100644 --- a/programs/system/shell/system/string.h +++ b/programs/system/shell/system/string.h @@ -13,7 +13,8 @@ void strcpy(char strDest[], const char strSource[]); char* strncpy(char *strDest, const char *strSource, unsigned n); int strlen(const char* string); char* strchr(const char* string, int c); +char* strrchr(const char* string, int c); void _itoa(int i, char *s); void reverse(char *s); void itoa(int i, char *s); -int _atoi ( char *s ); +int _atoi( char *s );