Closed (fixed)
Project:
Drush
Component:
Documentation
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
6 May 2011 at 22:09 UTC
Updated:
4 Jan 2014 at 00:53 UTC
Jump to comment: Most recent, Most recent file
The topic discussing standalone drush scripts should probably clarify that they only work on Windows. The test for them should skip if test is run on Windows ... Unless I am missing something and the shebang should work on Windows.
We might want to include or copy a couple functions into the test framework. Am thinking of drush_is_windows() and friends.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | skip_shebang_check_on_windows_7.patch | 3.66 KB | beltofte |
| #4 | skip_shebang_check_on_windows.patch | 3.64 KB | greg.1.anderson |
Comments
Comment #1
greg.1.anderson commentedThe shebang scripts will probably work on Windows under mingw / cygwin, but you are right, the test should be skipped on other platforms.
Comment #2
greg.1.anderson commentedHere is a test for bash prior to testing the shebang script. We just naively assume that bash is present on Linux (Mac) and Cygwin (MINGW), and not on Windows, rather than do 'which bash' or equiv. on every bootstrap. The test is superfluous, in a way, because without bash, we will never be called in a way that activates this code; however, it does serve as documentation of sorts what the intention is. I don't know, maybe that makes the test potentially harmful? (If we're wrong in drush_has_bash, we turn off behavior for no good reason.)
Note that with or without this patch, you can run shebang scripts via
drush php-script c:/path/to/scripton both Linux and Windows.Comment #3
moshe weitzman commentedMissing the attachment
Comment #4
greg.1.anderson commentedOops. Here it is.
Comment #5
greg.1.anderson commentedAdd windows tag
Comment #6
moshe weitzman commentedSeems like a useful enhancement. Lets enhance the patch so that we invoke the hellounish script with `drush script hellounish.script` when running on windows. Am referring to coreTest.php
Comment #7
beltofteUpdated the patch to current HEAD.
@moshe: Not 100% sure how the test case should be altered here. Let's discuss it on our Skype meeting later today.
Comment #8
greg.1.anderson commentedSo, about the line
elseif (((strpos($args[1], ' ') !== FALSE) || (!ctype_alnum($args[1][0]))) && (_drush_is_drush_shebang_script($args[2])))...This allows folks to pass arguments or options to drush on the shebang line, but it only works if you use the absolute path to drush; it cannot be made to work with #!/usr/bin/env drush. I don't think anyone is using this feature, and calling drush_set_option at the beginning of your script is a fine alternative, so I think this code block could be dropped with no ill effects.
Comment #9
moshe weitzman commented@greg - can you clarify what patch you are envisoning here. not sure i can parse what you mean.
Comment #10
greg.1.anderson commentedI investigated #8 further and discovered that I was WRONG, that code is necessary for all shebang scripts.
Comment #11
moshe weitzman commentedThanks. So #7 looks fine to me. Any objection?
Comment #12
greg.1.anderson commentedWorks on Linux; I'm fine with committing it.
Comment #13
moshe weitzman commentedcommitted to master