diff -urp global-6.6.9/libutil/args.c global-6.6-9/libutil/args.c --- global-6.6.9/libutil/args.c 2022-12-12 01:38:21 +1000 +++ global-6.6-9/libutil/args.c 2022-12-13 11:57:36 +1000 @@ -46,6 +46,19 @@ static char *const *argslist; static FILE *ip; static GFIND *gp; +#ifdef __DJGPP__ +static char cwd[PATH_MAX]; + +/* + * CWD is global on DOS, restore it on exit. + */ +void +restorecwd(void) +{ + chdir(cwd); +} +#endif + /** * args_open: * @@ -193,6 +206,11 @@ preparse_options(int argc, char *const * extern const char *short_options; extern struct option const long_options[]; +#ifdef __DJGPP__ + getcwd(cwd, PATH_MAX); + atexit(restorecwd); +#endif + /* * restart scanning of the same argv by setting optind = 1. */