Thanks for sending this to the mailing list. I don't know VBscript, so
I can't comment on the validity of the patch myself, but I'd like to
point out that you should probably resend it as a proper patch (with a
commit-message describing what the patch does and all).
Then, if no one objects, it will probably be merged.
> http://code.google.com/p/msysgit/issues/detail?id=535
>
> Alex.
>
> diff --git a/share/WinGit/Git Bash.vbs b/share/WinGit/Git Bash.vbs
> index 365189b..6e90fe0 100644
> --- a/share/WinGit/Git Bash.vbs
> +++ b/share/WinGit/Git Bash.vbs
> @@ -1,10 +1,6 @@
> +Set WshObj = CreateObject("WScript.Shell")
> ' If there is an argument, use it as the directory to change to.
> If WScript.Arguments.Length=1 Then
> - Set WshObj = CreateObject("WScript.Shell")
> - WshObj.CurrentDirectory = WScript.Arguments(0)
> + path = Replace(wscript.arguments(0),"\","/")
> End If
> -
> -' Launch the shortcut in the current directory which has the same
> -' base name as this script.
> -Set AppObj = CreateObject("Shell.Application")
> -AppObj.ShellExecute(Replace(WScript.ScriptFullName, ".vbs", ".lnk"))
> +WshObj.run("bash.exe -c 'cd """ & path & """ && bash -il'")
>
You're killing all the comments, probably because they'd become stale
otherwise. But perhaps you should add some new ones to describe what
the code does?
On Wed, 9 Feb 2011, con...@aleksoft.net wrote:
> On Feb 7, 12:09�pm, Erik Faye-Lund <kusmab...@gmail.com> wrote:
> > Thanks for sending this to the mailing list. I don't know VBscript, so
> > I can't comment on the validity of the patch myself, but I'd like to
> > point out that you should probably resend it as a proper patch (with a
> > commit-message describing what the patch does and all).
> >
> > Then, if no one objects, it will probably be merged.
> >
> >
> > >http://code.google.com/p/msysgit/issues/detail?id=535
>
> Here is another patch. The first version assumed that the git\bin folder
> was on the PATH. This version removes this assumption and
> unconditionally adds the git\bin to the process level PATH environment
> variable, it does not affect other processes and is discarded when the
> running script quits.
I lean towards applying it without review if there is nobody can review
it, since you obviously put in some amount of work, and I do not want to
let this be spent in vain.
Objections, anyone?
Ciao,
Dscho
Objection.
Quickly trying this out shows some problems. I assume the last
attachment is the right one. On my system I have git installed with
use git from cmd prompt so none of git is actually in my PATH except
the git.cmd script. Doing
wscript "c:\Program Files (x86)\Git\Git Bash.vbs" c:\src\git.git
works with the old version but does not work with the new version. I
get 'The system cannot find the file specified' - it can't find
'bash.exe'
Fixing it to use the actual path to bash.exe on my system results in a
shell window flashing up then disappearing immediately.
Also - if no argument is provided, the 'path' variable will be
undefined by the last line.
Thanks.
Alex, do you think you can fix it without a flashing cmd window?
Ciao,
Dscho
The following appears to work for me. I suspect using
%ProgramFiles(x86)% is wrong for non-x64 people and possibly should be
using FileSystemObject.GetTemporaryFolder() or something. In this
version I create a temporary shotcut and launch that. All the various
attempts to execute bash -c 'cd somewhere; bash --login -i' failed to
work in some way or another.
--- begin ---
Option Explicit
Dim shell, path, bash, code, temp
Set shell = CreateObject("WScript.Shell")
bash = shell.ExpandEnvironmentStrings("%ProgramFiles(x86)%") &
"\Git\bin\bash.exe"
temp = shell.ExpandEnvironmentStrings("%TEMP%")
Dim link : Set link = shell.CreateShortCut(temp & "\gitlaunch.lnk")
link.TargetPath = bash
link.Arguments = "--login -i"
link.WindowStyle = 1
If WScript.Arguments.Length > 0 Then link.WorkingDirectory =
WScript.Arguments(0)
link.Save
Dim app : Set app = CreateObject("Shell.Application")
app.ShellExecute(temp & "\gitlaunch.lnk")
--- end ---
I just realised that what I tested is the last attachment on the
msysGit issue 535 - but there is also a patch in this thread - which I
didn't see.
As pointed out in issue #535 the explorer integration menu item does not
open UNC paths. This patch creates a temporary shortcut item with the
target path set before it executes the bash program and solves this issue.
Suggested-by: Alex Ivanov <vo...@aleksoft.net>
Signed-off-by: Pat Thoyts <patt...@users.sourceforge.net>
---
Looking again at the patch in this thread - it does work ok. However
we get two bash
shells running now where we might just have one if we go with my
approach of creating
a temporary shortcut. I took the method of identifying the Git
location from the previous
patch and added this to my version to create this one.
I reckon this provides the best of both -- needs checking on 32 bit
Windows by someone.
share/WinGit/Git Bash.vbs | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/share/WinGit/Git Bash.vbs b/share/WinGit/Git Bash.vbs
index 365189b..0676d22 100644
--- a/share/WinGit/Git Bash.vbs
+++ b/share/WinGit/Git Bash.vbs
@@ -1,11 +1,18 @@
-' If there is an argument, use it as the directory to change to.
-If WScript.Arguments.Length=1 Then
- Set WshObj = CreateObject("WScript.Shell")
- WshObj.CurrentDirectory = WScript.Arguments(0)
-End If
+Option Explicit
-' Launch the shortcut in the current directory which has the same
-' base name as this script.
-Set AppObj = CreateObject("Shell.Application")
-AppObj.ShellExecute(Replace(WScript.ScriptFullName, ".vbs", ".lnk"))
+Dim shell : Set shell = CreateObject("WScript.Shell")
+Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
+Dim gitdir : gitdir =
Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\"))
+Dim bash : bash = fso.BuildPath(gitdir, "bin\sh.exe")
+Dim linkfile : linkfile = fso.GetTempName() & ".lnk"
+
+Dim link : Set link = shell.CreateShortCut(linkfile)
+link.TargetPath = bash
+link.Arguments = "--login -i"
+link.WindowStyle = 1
+If WScript.Arguments.Length > 0 Then link.WorkingDirectory =
WScript.Arguments(0)
+link.Save
+
+Dim app : Set app = CreateObject("Shell.Application")
+app.ShellExecute linkfile
+fso.DeleteFile linkfile
--
1.7.4.msysgit.0
This is why I don't like attachments in Bug trackers.
Anyway, I think we're good to go; hopefully Alex will give his ACK?
Ciao,
Dscho
Alex.
---
diff --git a/share/WinGit/Git Bash.vbs b/share/WinGit/Git Bash.vbs
index ce280f8..a85e6fc 100644
--- a/share/WinGit/Git Bash.vbs
+++ b/share/WinGit/Git Bash.vbs
@@ -1,10 +1,18 @@
-' If there is an argument, use it as the directory to change to.
-If WScript.Arguments.Length=1 Then
- Set WshObj = CreateObject("WScript.Shell")
- WshObj.CurrentDirectory = WScript.Arguments(0)
-End If
+Option Explicit
-' Launch the shortcut in the current directory which has the same
-' base name as this script.
-Set AppObj = CreateObject("Shell.Application")
-AppObj.ShellExecute(Replace(WScript.ScriptFullName, ".vbs", ".lnk"))
+Dim shell : Set shell = CreateObject("WScript.Shell")
+Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
+Dim gitdir : gitdir = Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\"))
+Dim bash : bash = fso.BuildPath(gitdir, "bin\sh.exe")
+Dim linkfile : linkfile = fso.GetTempName() & ".lnk"
+
+Dim link : Set link = shell.CreateShortCut(linkfile)
+link.TargetPath = bash
+link.Arguments = "--login -i"
+link.WindowStyle = 1
+If WScript.Arguments.Length > 0 Then link.WorkingDirectory = WScript.Arguments(0)
+link.Save
+Dim app : Set app = CreateObject("Shell.Application")
+app.ShellExecute linkfile
+wscript.sleep(500)
+fso.DeleteFile linkfile
OK - I've added that plus GetTempName just makes a file name so I had
to join it to the path to the temporary directory or it tried to
create the shortcut in %windir% when launched from explorer.
With these two additional fixes its pushed to devel now.
Pat Thoyts
On Fri, 18 Feb 2011, Pat Thoyts wrote:
> On 18 February 2011 01:02, alex <ale...@aleksoft.net> wrote:
> > I get access denied on this line 50% of time on the last line
> > fso.DeleteFile linkfile
> >
> > Inserting wscript.sleep(500) immediately above it fixed the problem.
> > Otherwise it works ok.
>
> OK - I've added that plus GetTempName just makes a file name so I had to
> join it to the path to the temporary directory or it tried to create the
> shortcut in %windir% when launched from explorer. With these two
> additional fixes its pushed to devel now.
Thanks, both!
Dscho