From: ssh AT sgi DOT com (Steven Hein) Subject: Re: pdksh and UNC paths 17 Dec 1998 23:13:32 -0800 Message-ID: <3679433F.F185E6ED.cygnus.gnu-win32@cray.com> References: <19981217132703 DOT 547 DOT rocketmail AT send105 DOT yahoomail DOT com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------4FE57715470D85C1DA669911" To: gnu-win32 AT cygnus DOT com This is a multi-part message in MIME format. --------------4FE57715470D85C1DA669911 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I was right! It only took me about a half-hour this morning to find and fix the pdksh UNC path problems. And, while I was in there, I also made the changes necessary to allow paths beginning with drive letter designations (i.e. 'cd c:/winnt' or 'cd //f'). That was pretty easy, since the drive letter code was already in there for OS/2 support. I don't really have a public web site set up right now where I can put the diffs for this fix, so I'm attaching the output of 'diff -upr' for the 3 files that changed. If there's a different format/method that I should use for making those diffs available, let me know! Otherwise, ksh fans enjoy!! Steve Earnie Boyd wrote: > > ---Steven Hein wrote: > > > > Just a quick pdksh question. > > > > I'm running pdksh 5.2.13, with 20.1 (NT4 SP3) and it's great! Just > one > > problem: the 'cd' command doesn't understand any UNC path notation > > (like bash does), so I can't 'cd' onto the network. (I can if I map > > a network path to a local drive letter, then mount that drive letter > > to a unix path). Also, I can't use the "//" notation > > to cd to another local drive. > > > > I'm pretty sure that I could add this functionality to pdksh, but > > before I try, has anyone else added this to pdksh? > > No. But, look for the where the code is removing multiple // > occurences and modify that. > > == > - \\||// > -------------------o0O0--Earnie--0O0o------------------- > -- earnie_boyd AT yahoo DOT com -- > -- http://www.freeyellow.com/members5/gw32/index.html -- > ----------------------ooo0O--O0ooo---------------------- > > PS: Newbie's, you should visit my page. > _________________________________________________________ > DO YOU YAHOO!? > Get your free @yahoo.com address at http://mail.yahoo.com -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Hein (ssh AT sgi DOT com) Engineering Diagnostics/Software Silicon Graphics, Inc. 1050 Lowater Road Phone: (715) 726-8410 Chippewa Falls, WI 54729 Fax: (715) 726-6715 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --------------4FE57715470D85C1DA669911 Content-Type: text/plain; charset=us-ascii; name="pdksh-5.2.13-path.diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pdksh-5.2.13-path.diffs" diff -upr pdksh-5.2.13.original/c_ksh.c pdksh-5.2.13.new/c_ksh.c --- pdksh-5.2.13.original/c_ksh.c Mon Sep 22 18:40:30 1997 +++ pdksh-5.2.13.new/c_ksh.c Thu Dec 17 11:22:58 1998 @@ -6,6 +6,10 @@ #include "ksh_stat.h" #include +#ifdef __CYGWIN__ +#include +#endif /* __CYGWIN__ */ + int c_cd(wp) char **wp; @@ -107,6 +111,7 @@ c_cd(wp) else #endif /* S_ISLNK */ { + simplify_path(Xstring(xs, xp)); rval = chdir(try = Xstring(xs, xp)); } @@ -145,8 +150,12 @@ c_cd(wp) /* Set PWD */ if (pwd) { - set_current_wd(pwd); - setstr(pwd_s, pwd); +#ifdef __CYGWIN__ + char ptmp[PATH]; /* larger than MAX_PATH */ + cygwin_conv_to_full_posix_path(pwd, ptmp); +#endif /* __CYGWIN__ */ + set_current_wd(ptmp); + setstr(pwd_s, ptmp); } else { set_current_wd(null); pwd = Xstring(xs, xp); diff -upr pdksh-5.2.13.original/path.c pdksh-5.2.13.new/path.c --- pdksh-5.2.13.original/path.c Sat Feb 10 12:47:42 1996 +++ pdksh-5.2.13.new/path.c Thu Dec 17 11:23:35 1998 @@ -82,7 +82,7 @@ make_path(cwd, file, cdpathp, xsp, phys_ file = null; if (!ISRELPATH(file)) { - *phys_pathp = 0; + phys_pathp = 0; use_cdpath = 0; } else { if (file[0] == '.') { @@ -150,16 +150,17 @@ simplify_path(path) int isrooted; char *very_start = path; char *start; +char ptmp[5000]; if (!*path) return; if ((isrooted = ISROOTEDPATH(path))) very_start++; -#ifdef OS2 +#if defined(OS2) || defined(__CYGWIN__) if (path[0] && path[1] == ':') /* skip a: */ very_start += 2; -#endif /* OS2 */ +#endif /* OS2 || __CYGWIN__ */ /* Before After * /foo/ /foo @@ -169,12 +170,18 @@ simplify_path(path) * .. .. * ./foo foo * foo/../../../bar ../../bar - * OS2: + * OS2 (and CYGWIN?): * a:/foo/../.. a:/ * a:. a: * a:.. a:.. * a:foo/../../blah a:../blah */ + +#ifdef __CYGWIN__ + /* preserve leading double-slash on pathnames (for UNC paths) */ + if (path[0] && ISDIRSEP(path[0]) && path[1] && ISDIRSEP(path[1])) + very_start++; +#endif /* __CYGWIN__ */ for (cur = t = start = very_start; ; ) { /* treat multiple '/'s as one '/' */ diff -upr pdksh-5.2.13.original/sh.h pdksh-5.2.13.new/sh.h --- pdksh-5.2.13.original/sh.h Sun Aug 03 19:00:41 1997 +++ pdksh-5.2.13.new/sh.h Thu Dec 17 10:20:00 1998 @@ -292,6 +292,12 @@ extern int ksh_execve(char *cmd, char ** * os2 /foo no yes no * os2 foo no no yes * os2 ../foo no no yes + * cyg /foo yes yes no + * cyg foo no no yes + * cyg ../foo no no yes + * cyg a:/foo yes yes no + * cyg a:foo no no yes + * cyg a:../foo no no yes */ #ifdef OS2 # define PATHSEP ';' @@ -313,9 +319,16 @@ extern char *ksh_strrchr_dirsep(const ch # define DIRSEP '/' # define DIRSEPSTR "/" # define ISDIRSEP(c) ((c) == '/') -# define ISABSPATH(s) ISDIRSEP((s)[0]) -# define ISROOTEDPATH(s) ISABSPATH(s) -# define ISRELPATH(s) (!ISABSPATH(s)) +# ifdef __CYGWIN__ +# define ISABSPATH(s) \ + ((((s)[0] && (s)[1] == ':' && ISDIRSEP((s)[2]))) || ISDIRSEP((s)[0])) +# define ISROOTEDPATH(s) ISABSPATH(s) +# define ISRELPATH(s) (!(s)[0] || ((s)[1] != ':' && !ISDIRSEP((s)[0]))) +# else /* __CYGWIN__ */ +# define ISABSPATH(s) ISDIRSEP((s)[0]) +# define ISROOTEDPATH(s) ISABSPATH(s) +# define ISRELPATH(s) (!ISABSPATH(s)) +# endif /* __CYGWIN__ */ # define FILECHCONV(c) c # define FILECMP(s1, s2) strcmp(s1, s2) # define FILENCMP(s1, s2, n) strncmp(s1, s2, n) --------------4FE57715470D85C1DA669911-- - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".