This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: $PATH contains dot but unclear where it comes from


On Thu, Feb 6, 2014 at 10:14 AM, Csaba Raduly wrote:
> Hi Robert,
>
> On Thu, Feb 6, 2014 at 10:01 AM, Robert Klemme  wrote:
>> Hi,
>>
>> in cygwin64 on Win 7 64 bit I find "." in $PATH:
>>
>> $ echo "$PATH" | tr : \\n | egrep '^\.$'
>> .
>>
>> However, I was not able to detect where this came from.  It's neither
>> in the Windows system environment variables nor in the user
>> environment variables - as you can also see on a cmd prompt:
>
> Windows always looks into the current directory when searching for
> programs, so '.' is usually not in the Winows version of PATH (which
> Cygwin imports).

I know. But this is completely irrelevant here as I am trying to
determine how the dot appeared in $PATH.

> Almost certainly, the dot was put into the PATH by one of the Bash
> initialization files. Here are some off the top of my head (`info
> bash` , 6.2 Bash startup files, has the complete list).
>
> /etc/profile
> /etc/bash.bashrc
> ~/.bash_profile
> ~/.profile
> ~/.bashrc

Apparently you did not really read my last email.

> You can try running
>
> bash -x --login
>
> This will spew the shell commands being executed while interpreting
> the startup scripts (make sure you have a large scroll-back buffer :)
> Alternatively
>
> bash -x --login > bash_init.txt 2>&1
>
> then type 'exit' blindly into the terminal (maybe 'tee' would work
> better but I don't have access to Cygwin right now).
>
> If you saved to a file, you can grep for PATH and try to identify
> which initialization file put the dot in.

I should have mentioned that I did just that - to no avail.

$ echo exit | bash --login -i -x 2>|log
$ egrep -n 'PATH=(.:|.*:\.($|:))' log | head
1:+ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
140:+++ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.:/sbin:/usr/sbin:/usr/local/sbin
145:+++ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.:/sbin:/usr/sbin:/usr/local/sbin
152:+++ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.:/sbin:/usr/sbin:/usr/local/sbin
159:+++ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.:/sbin:/usr/sbin:/usr/local/sbin
166:+++ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.:/sbin:/usr/sbin:/usr/local/sbin
171:+++ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.:/sbin:/usr/sbin:/usr/local/sbin
178:+++ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.:/sbin:/usr/sbin:/usr/local/sbin
183:+++ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.:/sbin:/usr/sbin:/usr/local/sbin
190:+++ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.:/sbin:/usr/sbin:/usr/local/sbin

Also manual inspection does not show any line where the dot is
introduced.  The first line with an assignment to PATH which contains
the dot in the trace output is this one in /etc/profile:

PATH="/usr/local/bin:/usr/bin:${PATH}"

In the trace (see above):

+ PATH=/usr/local/bin:/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.

As you can see the dot is already there.  It seems it appears
somewhere in the mintty launching process.

Cheers

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

--
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]