git-gui: mc cannot be used before msgcat has been loaded
[git/dkf.git] / git-gui--askpass
blob12e117ecb11afabef1d0d751ebee442ce515dc1e
1 #!/bin/sh
2 # Tcl ignores the next line -*- tcl -*- \
3 exec wish "$0" -- "$@"
5 # This is a trivial implementation of an SSH_ASKPASS handler.
6 # Git-gui uses this script if none are already configured.
8 set answer {}
9 set yesno 0
10 set rc 255
12 if {$argc < 1} {
13 set prompt "Enter your OpenSSH passphrase:"
14 } else {
15 set prompt [join $argv " "]
16 if {[regexp -nocase {\(yes\/no\)\?\s*$} $prompt]} {
17 set yesno 1
21 message .m -text $prompt -justify center -aspect 4000
22 pack .m -side top -fill x -padx 20 -pady 20 -expand 1
24 entry .e -textvariable answer -width 50
25 pack .e -side top -fill x -padx 10 -pady 10
27 if {!$yesno} {
28 .e configure -show "*"
31 frame .b
32 button .b.ok -text OK -command finish
33 button .b.cancel -text Cancel -command {destroy .}
35 pack .b.ok -side left -expand 1
36 pack .b.cancel -side right -expand 1
37 pack .b -side bottom -fill x -padx 10 -pady 10
39 bind . <Visibility> {focus -force .e}
40 bind . <Key-Return> finish
41 bind . <Key-Escape> {destroy .}
42 bind . <Destroy> {exit $rc}
44 proc finish {} {
45 if {$::yesno} {
46 if {$::answer ne "yes" && $::answer ne "no"} {
47 tk_messageBox -icon error -title "Error" -type ok \
48 -message "Only 'yes' or 'no' input allowed."
49 return
53 set ::rc 0
54 puts $::answer
55 destroy .
58 wm title . "OpenSSH"
59 tk::PlaceWindow .