Forum Moderators: coopster

Message Too Old, No Replies

set include path in Windows from command line

bug that is not a bug

         

coopster

8:49 pm on Apr 16, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



According to a "bogus" bug report at PHP [bugs.php.net] this should work just fine in Windows according to the PHP for Windows developers but note the output I am getting, same as the original bug reporter:

php -d "include_path='C:\;C:\var\includes;C:\var\www\includes'" -r "print ini_get('include_path');"

// returns: 
'C:\

I can indeed duplicate the issue and I've tested it on a Windows box running XP Pro SP2 and another running SP3. Both boxes are running the latest Windows version of PHP, PHP 5.2.9-2. Zip version, not installer.

Note that if I duplicate the double quotation marks rather than attempt to use single quotation marks, I get the expected output:

php -d "include_path=""C:\;C:\var\includes;C:\var\www\includes""" -r "print ini_get('include_path');"

// returns: 
C:\;C:\var\includes;C:\var\www\includes

Are there any Windows pros that can explain what is happening here?

coopster

2:13 pm on May 5, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



In a completely unrelated but recent conversation with a technician from the HP security team I was told that the issue is likely a Windows OS shell escape issue. I was trying to run some other commands using command line switches where the first character was the hyphen and was instructed to escape using the backslash character. I realized I was escaping these characters by doubling them up in the example in my first message, but confirmed after using the escape from shell backslash ...

php -d "include_path=\"C:\;C:\var\includes;C:\var\www\includes\"" -r "print ini_get('include_path');"

// returns:  
C:\;C:\var\includes;C:\var\www\includes

So, that works too! Guess I have my answer.