@@ -200,6 +200,14 @@ proc safe_exec {cmd} {
200
200
eval exec [ make_arglist_safe $cmd ]
201
201
}
202
202
203
+ # executes one command in the background
204
+ # no redirections or pipelines are possible
205
+ # cmd is a list that specifies the command and its arguments
206
+ # calls `exec` and returns its value
207
+ proc safe_exec_bg {cmd} {
208
+ eval exec [ make_arglist_safe $cmd ] &
209
+ }
210
+
203
211
proc safe_open_file {filename flags} {
204
212
# a file name starting with " |" would attempt to run a process
205
213
# but such a file name must be treated as a relative path
@@ -2202,7 +2210,7 @@ proc do_gitk {revs {is_submodule false}} {
2202
2210
unset env(GIT_DIR)
2203
2211
unset env(GIT_WORK_TREE)
2204
2212
}
2205
- eval exec $cmd $revs " --" " --" &
2213
+ safe_exec_bg [ concat $cmd $revs " --" " --" ]
2206
2214
2207
2215
set env(GIT_DIR) $_gitdir
2208
2216
set env(GIT_WORK_TREE) $_gitworktree
@@ -2239,7 +2247,7 @@ proc do_git_gui {} {
2239
2247
set pwd [pwd ]
2240
2248
cd $current_diff_path
2241
2249
2242
- eval exec $exe gui &
2250
+ safe_exec_bg [ concat $exe gui]
2243
2251
2244
2252
set env(GIT_DIR) $_gitdir
2245
2253
set env(GIT_WORK_TREE) $_gitworktree
@@ -2270,16 +2278,18 @@ proc get_explorer {} {
2270
2278
2271
2279
proc do_explore {} {
2272
2280
global _gitworktree
2273
- set explorer [get_explorer]
2274
- eval exec $explorer [list [file nativename $_gitworktree ]] &
2281
+ set cmd [get_explorer]
2282
+ lappend cmd [file nativename $_gitworktree ]
2283
+ safe_exec_bg $cmd
2275
2284
}
2276
2285
2277
2286
# Open file relative to the working tree by the default associated app.
2278
2287
proc do_file_open {file } {
2279
2288
global _gitworktree
2280
- set explorer [get_explorer]
2289
+ set cmd [get_explorer]
2281
2290
set full_file_path [file join $_gitworktree $file ]
2282
- exec $explorer [file nativename $full_file_path ] &
2291
+ lappend cmd [file nativename $full_file_path ]
2292
+ safe_exec_bg $cmd
2283
2293
}
2284
2294
2285
2295
set is_quitting 0
@@ -2761,13 +2771,13 @@ if {[is_Windows]} {
2761
2771
regsub "/mingw../libexec/git-core/git-gui$" \
2762
2772
$normalized "/git-bash.exe" cmdLine
2763
2773
if {$cmdLine != $normalized && [file exists $cmdLine ]} {
2764
- set cmdLine [list " Git Bash" $cmdLine & ]
2774
+ set cmdLine [list " Git Bash" $cmdLine ]
2765
2775
} else {
2766
- set cmdLine [list " Git Bash" bash --login -l & ]
2776
+ set cmdLine [list " Git Bash" bash --login -l]
2767
2777
}
2768
2778
.mbar.repository add command \
2769
2779
-label [mc " Git Bash" ] \
2770
- -command {eval exec [ auto_execok start] $cmdLine }
2780
+ -command {safe_exec_bg [ concat [ list [ auto_execok start]] $cmdLine ] }
2771
2781
}
2772
2782
2773
2783
if {[is_Windows] || ![is_bare]} {
0 commit comments