Skip to contentSkip to conversation

Support DOS paths in dash

PATCH Eric Blake 3 participants 4 messages Sep 30, 2014 – Oct 4, 2014 10 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Eric Blake

author
#10 lore raw

[I noticed an old thread in my inbox while packaging dash 0.5.8 for Cygwin]

On 03/28/2013 09:08 AM, Edward Lam wrote [to the cygwin list]:

Quoted 12 lines
Quoted 11 lines

The problem is that dash tries to convert c:/windows to an absolute path, since it doesn't start with /. I suppose I could teach dash to recognize [letter]:/ as absolute paths, although that makes dash larger, and puts a burden on me (since I can guarantee upstream dash won't accept such a patch).

Quoted 1 line

I just don't care enough for DOS paths so I won't fix.

Me neither. And since you can use /cygdrive/c, not c:/, I won't bother to fix it.

Quoted 8 lines

Hi Folks,

I finally got down to looking at how to fix this in dash and came up with the attached patch (against dash-0.5.7). It's simple enough and so cd now works.

Please consider this for Cygwin.

I'm not interested in burdening the cygwin build of dash with a one-off patch, so I'd like to gauge the upstream thoughts - is it worth including platform-specific patches like this (no penalty to build size of non-cygwin platforms, and on cygwin, it allows 'cd c:/' to behave as shorthand for 'cd /cygdrive/c/')? If the patch lands in dash.git, then I'll rebuild the cygwin port of dash to include a backport (rather than waiting for 0.5.9 to be released). If there is no interest, I'd rather just drop the patch. The cygwin community already states that /cygdrive/c notation is the official way to access drive letters, and that if 'c:/' works it is nice, but it is not a design goal to always have it work.

Quoted 13 lines
cd.new.c renamed from cd.c +3 -0
@@ -38,6 +38,9 @@
 #include <string.h>
 #include <unistd.h>
 #include <limits.h>
+#ifdef __CYGWIN__
+#include <sys/cygwin.h>
+#endif
 
 /*
  * The cd and pwd commands.

cd.new.c line 202

Quoted 6 lines
cd.new.c renamed from cd.c +3 -0
@@ -194,6 +197,11 @@
 	char *cdcomppath;
 	const char *lim;
 
+#ifdef __CYGWIN__
+        char pathbuf[PATH_MAX + 1];
+        cygwin_conv_to_full_posix_path (dir, pathbuf);

By the way, cygwin_conv_to_full_posix_path() is deprecated (it suffers from possible buffer overflow); these days, it's preferred to use:

cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_RELATIVE, string, pathbuf,
sizeof(pathbuf))

So, if there is interest in this patch upstream, I can respin it.

Quoted 7 lines
cd.new.c renamed from cd.c +2 -0
+	 dir = pathbuf;
+#endif
 	cdcomppath = sstrdup(dir);
 	STARTSTACKSTR(new);
 	if (*dir != '/') {
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#11 lore raw
Quoted 12 lines · Eric Blake

I'm not interested in burdening the cygwin build of dash with a one-off patch, so I'd like to gauge the upstream thoughts - is it worth including platform-specific patches like this (no penalty to build size of non-cygwin platforms, and on cygwin, it allows 'cd c:/' to behave as shorthand for 'cd /cygdrive/c/')? If the patch lands in dash.git, then I'll rebuild the cygwin port of dash to include a backport (rather than waiting for 0.5.9 to be released). If there is no interest, I'd rather just drop the patch. The cygwin community already states that /cygdrive/c notation is the official way to access drive letters, and that if 'c:/' works it is nice, but it is not a design goal to always have it work.

It's fine by me.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#12 lore raw
Quoted 18 lines · Herbert Xu
Quoted 12 lines · Eric Blake

I'm not interested in burdening the cygwin build of dash with a one-off patch, so I'd like to gauge the upstream thoughts - is it worth including platform-specific patches like this (no penalty to build size of non-cygwin platforms, and on cygwin, it allows 'cd c:/' to behave as shorthand for 'cd /cygdrive/c/')? If the patch lands in dash.git, then I'll rebuild the cygwin port of dash to include a backport (rather than waiting for 0.5.9 to be released). If there is no interest, I'd rather just drop the patch. The cygwin community already states that /cygdrive/c notation is the official way to access drive letters, and that if 'c:/' works it is nice, but it is not a design goal to always have it work.

Quoted 2 lines

It's fine by me.

Is that a yes to allow platform-specific patches into dash?

Thanks,
-Edward

#13 lore raw
Quoted 18 lines · Edward Lam
Quoted 18 lines · Herbert Xu
Quoted 12 lines · Eric Blake

I'm not interested in burdening the cygwin build of dash with a one-off patch, so I'd like to gauge the upstream thoughts - is it worth including platform-specific patches like this (no penalty to build size of non-cygwin platforms, and on cygwin, it allows 'cd c:/' to behave as shorthand for 'cd /cygdrive/c/')? If the patch lands in dash.git, then I'll rebuild the cygwin port of dash to include a backport (rather than waiting for 0.5.9 to be released). If there is no interest, I'd rather just drop the patch. The cygwin community already states that /cygdrive/c notation is the official way to access drive letters, and that if 'c:/' works it is nice, but it is not a design goal to always have it work.

Quoted 4 lines
Quoted 2 lines

It's fine by me.

Is that a yes to allow platform-specific patches into dash?

If there is zero impact on other platforms and it doesn't adversely impact the maintainability then yes.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt