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: Debug the skipping of .bashrc when bang out from vim PC version


On Aug 27, 1:55 am, AndyHancock <andymhanc...@gmail.com> wrote:
> It is often more covenient to use the Windows install of gvim than
> to fire up Cygwin's X-windows to run the Cygwin version of gvim.  In
> order to be able to bang out to run bash commands, I have this in my
> vimrc:
> 
>    shell=c:\cygwin\bin\bash.exe\ -i
> 
> This allows me to do things like
> 
>    !!ls
> 
> or
> 
>    :w !cat
> 
> However, this only works when I launch the Windows version of gvim
> from my Administrator account.  When I try those commands from a
> non-administrator account, I get:
> 
>    shell return 127 bash: ls: command not found
> 
> or
> 
>    shell return 127 bash: cat: command not found
> 
> It actually took a while to recognize this pattern with the
> administrator account.  I thought it would be simple to track down
> the cause after finding this.  I thought I could simply set
> 
>    shell=c:\cygwin\bin\bash.exe\ -i\ -v
> 
> Then I could do echo the results of the shell-outs to register a and
> paste them somewhere:
>
>   :redir @a
>   !!ls
>   :w !cat
>   :redir END 
>
> I confirmed that
> 
>    c:\cygwin\bin\bash.exe -i -v
> 
> actually echos every gruesome detail by issuing it from the command
> line.  However, setting vim's "shell" option to include the -v
> option *doesn't* seem to echo all the gruesome details regardless of
> whether I use an administrator or non-administrator account.
> 
> 1. Can anyone suggest a cause and/or solution to the inability of
> the non-administrator to shell out?
> 
> 2. What about why the -v option doesn't seem to work when included
> in vim's shell option?
> 
> 3. Can anyone suggest another way to troubleshoot the inability of
> the non-administrator account to shell out?

Here's some more information.  Both accounts have the same .bashrc, which sets
the $PATH.  I rely on the -i option supplied to the bash command to force the
execution of .bashrc.  I was hoping that the -v command would show me that
.bashrc was running by echoing the statements, but it doesn't.  I even put in

   echo Running bashrc

in the .bashrc, but no message shows (and no such text is sent to vim register
a).  Another confirmation that .bashrc is not being executed is that I shell out
with

   !!echo $PATH

and the path is the same as "echo %PATH%" issued from a DOS prompt.

Here is another test that I tried.  Logged in under the
non-administrator account, I ran the PC-based gvim as LocalAdmin.
That alone does not allow shelling out, even though I am prompted for
LocalAdmin's password when launching gvim.  I had to run gvim with elevated
privileges before I could shell out.  This entails running as Administrator (not
as LocalAdmin, though the process still invokes an authentication window for
LocalAdmin's password).  Only then would

   !!echo $PATH

give the path set by bashrc.  Otherwise, it gives a path that is identical to
%PATH% in a DOS shell.


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