diff --git a/programs/system/shell/cmd/cmd_cd.c b/programs/system/shell/cmd/cmd_cd.c index a0c597dfff..9fed95e904 100644 --- a/programs/system/shell/cmd/cmd_cd.c +++ b/programs/system/shell/cmd/cmd_cd.c @@ -1,11 +1,4 @@ -static inline void set_cwd(const char* cwd) -{ - __asm__ __volatile__( - "int $0x40" - ::"a"(30),"b"(1),"c"(cwd)); -}; - int cmd_cd(char dir[]) { diff --git a/programs/system/shell/globals.h b/programs/system/shell/globals.h index 11dd3bb8cf..5cefd96104 100644 --- a/programs/system/shell/globals.h +++ b/programs/system/shell/globals.h @@ -5,7 +5,7 @@ extern char PATH[256]; extern char PARAM[256]; char title[64]; -char cur_dir[256]; +char cur_dir[FILENAME_MAX]; /// =========================================================== @@ -16,8 +16,8 @@ unsigned ALIAS_NUM = 0; #define CMD_HISTORY_NUM 11 -char CMD[256]; -char CMD_HISTORY[CMD_HISTORY_NUM][256]; +char CMD[FILENAME_MAX * 2]; +char CMD_HISTORY[CMD_HISTORY_NUM][FILENAME_MAX * 2]; char CMD_NUM = 0; char CMD_HISTORY_NUM_REAL = 0; unsigned LAST_PID = 0; diff --git a/programs/system/shell/shell.c b/programs/system/shell/shell.c index c69318dcf3..72c82df3a9 100644 --- a/programs/system/shell/shell.c +++ b/programs/system/shell/shell.c @@ -129,16 +129,19 @@ if (sizeof (kol_struct70) != 25) } -strcpy(cur_dir, PATH); -dir_truncate(cur_dir); +//strcpy(cur_dir, PATH); +//dir_truncate(cur_dir); +getcwd(cur_dir, sizeof cur_dir); +//printf("curdir %s\n", cur_dir); con_set_cursor_height(con_get_font_height()-1); ALIASES = malloc(128*1024); -if (PARAM[0] == 0) +if (!PARAM || PARAM[0] == 0) { - strcpy(CMD, cur_dir); + strcpy(CMD, PATH); + dir_truncate(CMD); strcat(CMD, ".shell"); if ( !file_check(CMD) ) strcpy(CMD, "/sys/settings/.shell"); diff --git a/programs/system/shell/system/kolibri.c b/programs/system/shell/system/kolibri.c index 035b2ce763..d8706efaa6 100644 --- a/programs/system/shell/system/kolibri.c +++ b/programs/system/shell/system/kolibri.c @@ -436,3 +436,17 @@ int kol_clip_set(int n, char buffer[]) { asm volatile ("int $0x40"::"a"(54), "b"(2), "c"(n), "d"(buffer)); } + +void set_cwd(const char* cwd) +{ + __asm__ __volatile__( + "int $0x40" + ::"a"(30),"b"(1),"c"(cwd)); +}; + +int getcwd(char *buf, unsigned size) +{ + __asm__ __volatile__( + "int $0x40" + ::"a"(30),"b"(2),"c"(buf), "d"(size)); +} diff --git a/programs/system/shell/system/kolibri.h b/programs/system/shell/system/kolibri.h index 08dac34409..aa35580947 100644 --- a/programs/system/shell/system/kolibri.h +++ b/programs/system/shell/system/kolibri.h @@ -114,3 +114,6 @@ void kol_buffer_close(char name[]); int kol_clip_num(); char* kol_clip_get(int n); int kol_clip_set(int n, char buffer[]); +void set_cwd(const char* cwd); +int getcwd(char *buf, unsigned size); +