Closed (fixed)
Project:
Drush
Component:
Miscellaneous
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Jul 2010 at 11:03 UTC
Updated:
11 Nov 2010 at 20:00 UTC
Jump to comment: Most recent file
I was trying to get drush_make to work on a Windows/Cygwin environment when I noticed the following lines in drushrc.php:
// Specify additional directories to search for *.drush.inc files
// Use POSIX path separator (':')
$options['i'] = 'sites/default:profiles/myprofile';
The POSIX path separator causes a problem, because it breaks up the windows path ("C:\drush\drush_make") I needed to enter here. Cygwin offers a way to access the drush_make folder as /cygdrive/c/drush/drush_make, but entering that as include path didn't work.
Can we think of a way to support Windows paths? A simple solution would be to change the separator, but I don't know if that would break something. (At least it would break existing drushrc.php files when people try to upgrade).
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | drush-path-separators-845374-20.patch | 5.14 KB | marcvangend |
| #15 | drush-path-separators-845374-15.patch | 4.9 KB | marcvangend |
| #10 | 845374-10-include-path-comma-split.patch | 462 bytes | marcvangend |
| #10 | 845374-10-include-path-regex-split.patch | 473 bytes | marcvangend |
| #1 | command_inc_windows_paths.patch | 418 bytes | marcvangend |
Comments
Comment #1
marcvangendHere is a patch for command.inc, doing some regex magic on the $include string, so it will only split on a
:when it is not followed by a\.Comment #2
moshe weitzman commentedCan anyone think of a better solution here? How would windows users specify multiple paths after this patch? Would we need a docs change as well?
Comment #3
greg.1.anderson commentedIt works, as long as Windows users don't end their paths with a \. I'm not entirely happy with it myself, but so far I have not thought of a better solution -- except perhaps defining another $option that holds the path separator, which would allow Windows users to then use
c:\path1|d:\path2. I'm not sure what's best, but I'd prefer something non-magic like this to a complex regex like #1.Comment #4
marcvangendAfter the patch, the $include string will only be split on a colon when it is not followed by a backslash. That means that Windows users can define multiple include paths as follows:
$options['i'] = 'C:\drush\drush_make:C:\drush\examples';. This makes the patch backwards compatible with existing drushrc.php files, except for one edge case: when, on a non-windows OS, the first character of the second (or higher) path is a backslash, the string would not be split.[edit:]
@greg: It should not matter if windows users end their paths with a
\, because the regex splits the string on all colons that are not followed by a backslash. Preceding backslashes have no effect (assuming that I wrote the regex correctly :-)). I'm not a big fan of regex-based solutions myself, but changing the separator would break existing drushrc.php files, which is not ideal either.Comment #5
greg.1.anderson commentedYou're right, my brain was thinking of the : and the \ in the wrong order. Windows paths should not begin with \, so this regex isn't too bad. It's bad for my brain, though, which cannot help but read the above example as
C,\drush\drush_make,C,\drush\examples.Changing the separator could be be backwards-compatible if it was specified via an option that defaulted to
:.Note also that drush is inconsistent with path separators--my fault, I split --include-paths in rsync on
,instead of:. That's better for Windows, but I'm not happy with the inconsistency. :(Ambivalent about what to do here.
Comment #6
moshe weitzman commentedSeems like switching to comma separated makes sense here.
Comment #7
greg.1.anderson commentedBreaking
$options['i']is not catastrophic; I think I'd also vote for just switching to comma separated for all paths.Comment #8
marcvangendIt's been a while since the last post here... Time to make a choice and fix this? I'd be happy to supply another patch if necessary.
Comment #9
greg.1.anderson commentedI am really backlogged on my drush tasks, but I'm starting to work through it. I'd be happy to review a patch that split on , instead of :
Comment #10
marcvangendSo... here are two patches. One changes the colon delimiter to a comma delimiter - probably the simplest patch I've written so far :-)
The second patch is a slightly simplified version of the regex-patch from #1. Personally, I don't really have a preference for either solution, but dismissing this solution because it's 'magic' and 'complex' doesn't do it justice. The regex
:(?!\\)means: match a colon (:) when followed by ((? )) not (!) a backslash (escaped as\\). I tend to find regex difficult myself too, but seriously, they don't get much easier than this one.Anyway, I hope this helps to get one of these patches committed. Thanks.
Comment #11
greg.1.anderson commentedComment #12
jonhattanThe path separator for windows is
;and we have PATH_SEPARATOR constant in php: http://php.net/manual/en/dir.constants.php I think this is more appropiate than using a custom separator.Comment #13
greg.1.anderson commentedAgree with jonhattan. Ideally, this patch would fix --include-paths in rsync as well.
Comment #14
marcvangendOk, I didn't know about the path separator constant, thanks. I'll give it a shot later today.
Comment #15
marcvangendHere's a new patch, now targeting all occurrences of path separators I could find. The include path (which started this issue) and rsync have already been mentioned, but also php-script accepts a list of paths. This patch makes them use the PATH_SEPARATOR constant. I also updated the descriptions in core_drush_command() and the inline docs in example.drushrc.php.
I'm not sure what this piece of code does (around line 501 of core.drush.inc in function _core_path_aliases()):
It seems similar to the other path separator occurrences, but I couldn't figure out what the $project option does, so I left it as is.
Comment #16
jonhattanLooks good.
That piece of code is to compound the output of
drush statusand is not affected, as paths aren't merged with a PATH_SEPARATOR.Comment #17
marcvangendJonhattan, did you test the patch yourself on Windows? I now realize (oops!) that I forgot to mention something important when I posted the patch last night: I wrote it on my home linux machine and I have not tested it on Windows yet. I'll do some proper Windows testing asap, unless someone already did that.
Please set the issue back to RTBC if I'm being too cautious here.
Comment #18
jonhattanme? windows? no, it's not.
Comment #19
marcvangendHere's a new patch changing one more line of documentation in example.drushrc.php.
I have tested the --include and --script-path options on windows and the ; separator works fine. We do not use drush rsync here at the office(yet) so I wasn't able to test that. If someone can test rsync with this patch (if not on Windows, then at least in a unix environment), I think we can call this RTBC.
Comment #20
marcvangendForgot the attachment.
Comment #21
greg.1.anderson commentedNone of the drush maintainers do Windows, and historically, Windows patches sit around for a long long time before anyone wanders into the queue and accidentally tests them. I therefore suggest that this patch is RTBC. If there are problems with Windows remaining, someone will eventually come along and open a new issue.
Comment #22
marcvangendI agree. As long as this doesn't break anything on unix, this patch is de facto an improvement, even if it wouldn't work for all Windows users.
Comment #23
moshe weitzman commentedCommitted. Thanks much.