@@ -200,6 +200,14 @@ proc safe_exec {cmd} {
200200 eval exec [ make_arglist_safe $cmd ]
201201}
202202
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+
203211proc safe_open_file {filename flags} {
204212 # a file name starting with " |" would attempt to run a process
205213 # but such a file name must be treated as a relative path
@@ -2202,7 +2210,7 @@ proc do_gitk {revs {is_submodule false}} {
22022210 unset env(GIT_DIR)
22032211 unset env(GIT_WORK_TREE)
22042212 }
2205- eval exec $cmd $revs " --" " --" &
2213+ safe_exec_bg [ concat $cmd $revs " --" " --" ]
22062214
22072215 set env(GIT_DIR) $_gitdir
22082216 set env(GIT_WORK_TREE) $_gitworktree
@@ -2239,7 +2247,7 @@ proc do_git_gui {} {
22392247 set pwd [pwd ]
22402248 cd $current_diff_path
22412249
2242- eval exec $exe gui &
2250+ safe_exec_bg [ concat $exe gui]
22432251
22442252 set env(GIT_DIR) $_gitdir
22452253 set env(GIT_WORK_TREE) $_gitworktree
@@ -2270,16 +2278,18 @@ proc get_explorer {} {
22702278
22712279proc do_explore {} {
22722280 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
22752284}
22762285
22772286# Open file relative to the working tree by the default associated app.
22782287proc do_file_open {file } {
22792288 global _gitworktree
2280- set explorer [get_explorer]
2289+ set cmd [get_explorer]
22812290 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
22832293}
22842294
22852295set is_quitting 0
@@ -2761,13 +2771,13 @@ if {[is_Windows]} {
27612771 regsub "/mingw../libexec/git-core/git-gui$" \
27622772 $normalized "/git-bash.exe" cmdLine
27632773 if {$cmdLine != $normalized && [file exists $cmdLine ]} {
2764- set cmdLine [list " Git Bash" $cmdLine & ]
2774+ set cmdLine [list " Git Bash" $cmdLine ]
27652775 } else {
2766- set cmdLine [list " Git Bash" bash --login -l & ]
2776+ set cmdLine [list " Git Bash" bash --login -l]
27672777 }
27682778 .mbar.repository add command \
27692779 -label [mc " Git Bash" ] \
2770- -command {eval exec [ auto_execok start] $cmdLine }
2780+ -command {safe_exec_bg [ concat [ list [ auto_execok start]] $cmdLine ] }
27712781}
27722782
27732783if {[is_Windows] || ![is_bare]} {
0 commit comments