This is the mail archive of the
mailing list for the Cygwin project.
Re: Pass windows-style paths to the interpreter from the shebang line ?
Greetings, Timothy Madden!
> As Linda said, I would like to be able to execute my new script from a
> cygwin prompt and from a sh script, with a command like
> parseLog.php /logfile/
> For this to work, I think I need the shebang line.
For cygwin, seems so.
> So I tried "#! php"
> too, the problem is that bash will then invoke the following command to
> process my script:
> php /home/adrian/usr/local/bin/parseLog.php
Yep. I haven't run into this issue myself, due to executing scripts from
current directory at all times... *shrugs*
> Now remember that "php" here is the native Windows port that can not
> read that cygwin filename argument, begining with /home/adrian/...
The problem is not limited to php invocation, but also imposing restrictions
to the script usage.
If invocation issue could be solved by something like
$ cat /usr/bin/php
/c/usr/php-win32/php.exe `cygpath --mixed $1` $*
You'd have to deal with PHP arguments as well.
Simple solution to the latter I could think about is to write a PHP library
converting Cygwin paths into native windows paths, where you know you need
them. Not where some supposedly sophisticated utility thinks you have them.
> The solutions I could think of include:
> - compose a script named php, somewhere on PATH, written is sh,
> perl, python, even php,
Naaah, you'd run into loop with PHP. :)
> - get a cygwin port of php, that understands cygwin-style paths
> given on the command line. Although Cygwin setup.exe did not
> install such a port, I am happy to find here that there still
> is a cygwin port of php available.
There's pros and cons to use Cygwin ports when there's native version of the
same application is available.
> - have the cygwin port of bash detect if the
> interpreter binary from any shebang line is a cygwin
> application or a native application and compose the command
> line accordingly. Corinna Vinschen on this list says this is
> not as easy as it sounds, though
Yep, it's not. Especially not if there's a custom loader in executable.
Mixed paths would be safer to use inside Cygwin scripts. Just avoid using your
script with network share through UNC... :/
Andrey Repin (email@example.com) 10.11.2011, <16:15>
Sorry for my terrible english...
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple