1.7.35 Bash spawned by Perl has DOS-style argv0

John Warburton john@johnwarburton.net
Sat Feb 14 15:51:00 GMT 2015


Hello,

After upgrading my installation from about two months ago to 1.7.35, a
Bash shell opened by Perl (as used in Gnu Autotools) now sees
DOS-style paths in its $argv0 variable instead of Unix-style paths
and, consequently, errors occur. Before I upgraded my installation,
everything was fine.

Here is a simple test case I have written.

The first script displays $argv0 correctly in Unix style and runs a
Perl program.
The second script, a Perl program displays its $argv0 correctly in
Unix style, and executes a script in a Bash shell.
The third script displays its $argv0 and exits. This is where the
problem happens: its $argv0 is DOS style, and breaks Gnu Autotools

First, here is the output:

$ ./pathtest_1.sh
I have set argv0 to pathtest_1.sh and 0 to ./pathtest_1.sh
This is Bash version 4.3.33(1)-release
Now running Perl...
My absolute path is: /home/John/cygtest/perlpath.pl
Now to run Bash again, and view its argv...
After execution from Perl, I have set argv0 to
C:\cygwin64\home\John\cygtest\pathtest_2.sh
 and 0 to C:\cygwin64\home\John\cygtest\pathtest_2.sh
This is Bash Version 4.3.33(1)-release.

Here are the three programs. You can download them in a tarball here:
http://johnwarburton.com/unix-to-dos-path-problem.tar.gz

   Filename 1: pathtest_1.sh

argv0=${0##*/}
echo "I have set argv0 to ${argv0} and 0 to ${0}"
echo "This is Bash version ${BASH_VERSION}"
echo "Now running Perl..."

   Filename 2: perlpath.pl

use Cwd 'abs_path';
print "My absolute path is: ";
print abs_path($0);
print "\n";
print "Now to run Bash again, and view its argv...\n";
system ("./pathtest_2.sh");

   Filename 3: pathtest_2.sh

argv0=${0##*/}
echo "After execution from Perl, I have set argv0 to ${argv0} and 0 to ${0}"
echo "This is Bash version ${BASH_VERSION}"

Is anyone else experiencing this? Are there any ways to force Bash
shells run from Cygwin Perl to see Unix style paths, especially when
Perl itself reports a Unix style path?

Thank you for reading this.
John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 128272 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20150214/a4314525/attachment.obj>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list