diff --git a/kernel/config.c b/kernel/config.c index a2f6cd4..439a5ef 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -129,6 +129,10 @@ struct config Config = { /* unsigned ebda2move; */ 0, /* value for SWITCHES=/E:nnnn */ }; +/* master_env copied over command line area in + DOS_PSP, thus its size limited to 128 bytes */ +static char master_env[128] = "PATH=."; + STATIC seg_t base_seg BSS_INIT(0); STATIC seg_t umb_base_seg BSS_INIT(0); VFP lpTop BSS_INIT(0); @@ -293,6 +297,9 @@ void PreConfig(void) #ifdef DEBUG printf("Preliminary allocation completed: top at %p\n", lpTop); #endif + + /* initialize environment */ + fmemcpy(MK_PTR(char, DOS_PSP + 8, 0), master_env, sizeof(master_env)); } static void KernelAllocSFT(sfttbl FAR *p, unsigned files, int high) @@ -2066,8 +2073,8 @@ STATIC void _CmdInstall(PCStr p, int mode) if (len > sizeof args.ctBuffer - 2) len = sizeof args.ctBuffer - 2; /* trim too long line */ args.ctCount = (UBYTE)len; - args.ctBuffer[len] = '\r'; - args.ctBuffer[len+1] = 0; + args.ctBuffer[len-2] = '\r'; + args.ctBuffer[len-1] = '\0'; memcpy(args.ctBuffer, p, len); set_strategy(mode); @@ -2109,7 +2116,7 @@ VOID DoInstall(void) /* master_env copied over command line area in DOS_PSP, thus its size limited to 128 bytes */ -static char master_env[128] = "PATH=."; +/* static char master_env[128] = "PATH=."; */ /* !!! dirty hack: because bug in old FreeCOM, which wrongly process empty environment in MS-DOS style, garbage empty diff --git a/kernel/task.c b/kernel/task.c index 454328c..507b26b 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -136,7 +136,7 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path) { seg_t dst_seg = *penv_seg + 1; - /* enviornment contains: + /* environment contains: - 0 or more ASCIIZ strings (with variable definitions); - empty ASCIIZ string (one null character); - 16-bit counter (usually 1); @@ -151,6 +151,45 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path) *MK_PTR(UWORD, dst_seg, env_sz + 2) = 1; fstrcpy(MK_PTR(char, dst_seg, env_sz + 4), PriPathName); } + +#if DEBUG + { + seg_t dst_seg = *penv_seg + 1; + int i; + + printf("ChildEnv. env seg=0x%02x\n", dst_seg); + if (dst_seg) + { + const char FAR*p = MK_PTR(const char, dst_seg, 0); + /* loop through ASCIIZ env variables */ + if (*p) + while (*p) + { + printf("["); + for (; *p; p++) + if (*p == ' ') printf(""); + else printf("%c", *p); + printf("]\n"); + p++; + } + else + p++; /* even empty env must have 1 ("") ASCIIZ string */ + /* may be followed by empty string (just \0), 16bit count, ASCIIZ argv[0] */ + printf("End of Env marker = 0x%02x (should be 0)\n", *p); + printf("argv[0] present = %u\n", *MK_PTR(UWORD, dst_seg, env_sz + 2)); + p+=3; /* skip 16bit count and point to argv[0] */ + if (*p) + { + for (i = 0; p[i] && (i < 127); i++) + printf("%c", p[i]); + printf("\n"); + } + else + printf("No program name (argv[0]) supplied\n"); + } + } +#endif + return SUCCESS; } @@ -292,6 +331,32 @@ static void load_transfer(seg_t ds, exec_blk *ep, int mode) fcbcode = (get_cds1(p->ps_fcb1.fcb_drive) ? 0 : 0xff) | (get_cds1(p->ps_fcb2.fcb_drive) ? 0 : 0xff00); +#ifdef DEBUG + { + int i, ctCount=ep->exec.cmd_line->ctCount; + /* display full command line */ + if (ctCount > 127) + { + printf("load_transfer. CommantTail=%d count exceeds 127\n", ctCount); + ctCount = 127; + } + printf("load_transfer. CommandTail is:\n"); + /* use loop in case tail not '\0' terminated */ + if (ctCount) + { + for (i=0; i < ctCount; i++) + if (ep->exec.cmd_line->ctBuffer[i] == ' ') + printf(""); + else + printf("%c", ep->exec.cmd_line->ctBuffer[i]); + printf("\n"); + } + else + printf("\n"); + } +#endif + + /* Transfer control to the executable */ if (mode == LOADNGO) { diff --git a/sys/sys.c b/sys/sys.c index e3ea795..ed55d35 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -660,7 +660,7 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) char *comspec = getenv("COMSPEC"); if (opts->fnCmd || (comspec == NULL) || stat(comspec, &fstatbuf)) { - printf("%s: failed to find command interpreter (shell) file %s\n", pgm, (opts->fnCmd)?opts->fnCmd:"COMMAND.COM"); + printf("%s: failed to find command interpreter (shell) file %s\n", pgm, srcFile); exit(1); } } @@ -711,7 +711,7 @@ int main(int argc, char **argv) { char *comspec = getenv("COMSPEC"); if (!opts.fnCmd && (comspec != NULL)) - printf("%s: Trying shell from %COMSPEC%=\"%s\"\n", pgm, comspec); + printf("%s: Trying shell from %%COMSPEC%%=\"%s\"\n", pgm, comspec); if (opts.fnCmd || (comspec == NULL) || !copy(comspec, opts.dstDrive, "COMMAND.COM")) { printf("\n%s: failed to find command interpreter (shell) file %s\n", pgm, (opts.fnCmd)?opts.fnCmd:"COMMAND.COM"); @@ -1443,7 +1443,7 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename) open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, S_IREAD | S_IWRITE)) < 0) { - printf(" %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno); + printf(" %s: can't create\"%s\"\nDOS errnum %d\n", pgm, dest, errno); close(fdin); return FALSE; } @@ -1486,7 +1486,7 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename) }; #endif - printf("%lu Bytes transferred", copied); + printf("%lu Bytes transferred\n", copied); return TRUE; } /* copy */