Git fork
1#!/bin/sh
2# Tcl ignores the next line -*- tcl -*- \
3exec wish "$0" -- "$@"
4
5# This is an implementation of a simple yes no dialog
6# which is injected into the git commandline by git gui
7# in case a yesno question needs to be answered.
8#
9# The window title, which defaults to "Question?", can be
10# overridden via the optional `--title` command-line
11# option.
12
13set NS {}
14set use_ttk [package vsatisfies [package provide Tk] 8.5]
15if {$use_ttk} {
16 set NS ttk
17}
18
19set title "Question?"
20if {$argc < 1} {
21 puts stderr "Usage: $argv0 <question>"
22 exit 1
23} else {
24 if {$argc > 2 && [lindex $argv 0] == "--title"} {
25 set title [lindex $argv 1]
26 set argv [lreplace $argv 0 1]
27 }
28 set prompt [join $argv " "]
29}
30
31${NS}::frame .t
32${NS}::label .t.m -text $prompt -justify center -width 40
33.t.m configure -wraplength 400
34pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
35pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1
36
37${NS}::frame .b
38${NS}::frame .b.left -width 200
39${NS}::button .b.yes -text Yes -command {exit 0}
40${NS}::button .b.no -text No -command {exit 1}
41
42pack .b.left -side left -expand 1 -fill x
43pack .b.yes -side left -expand 1
44pack .b.no -side right -expand 1 -ipadx 5
45pack .b -side bottom -fill x -ipadx 20 -ipady 15
46
47bind . <Key-Return> {exit 0}
48bind . <Key-Escape> {exit 1}
49
50if {$::tcl_platform(platform) eq {windows}} {
51 set icopath [file dirname [file normalize $argv0]]
52 if {[file tail $icopath] eq {git-core}} {
53 set icopath [file dirname $icopath]
54 }
55 set icopath [file dirname $icopath]
56 set icopath [file join $icopath share git git-for-windows.ico]
57 if {[file exists $icopath]} {
58 wm iconbitmap . -default $icopath
59 }
60}
61
62wm title . $title
63tk::PlaceWindow .