summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-02-12 22:06:21 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-02-12 22:06:21 +0900
commit96c3de12eb717e33b175fd01a9aaaac84ea8d6af (patch)
tree768a95d1e435436a93b5b06db98caf53d1982214 /src
parent719dbb8bae14a5981b77255bb21ea75907a49d50 (diff)
downloadfzf-96c3de12eb717e33b175fd01a9aaaac84ea8d6af.tar.gz
Run 'become' only when the command template is properly evaluated
Diffstat (limited to 'src')
-rw-r--r--src/terminal.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 13968a39..18f83530 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -2863,19 +2863,21 @@ func (t *Terminal) Loop() {
switch a.t {
case actIgnore:
case actBecome:
- _, list := t.buildPlusList(a.a, false)
- command := t.replacePlaceholder(a.a, false, string(t.input), list)
- shell := os.Getenv("SHELL")
- if len(shell) == 0 {
- shell = "sh"
- }
- shellPath, err := exec.LookPath(shell)
- if err == nil {
- t.tui.Close()
- if t.history != nil {
- t.history.append(string(t.input))
+ valid, list := t.buildPlusList(a.a, false)
+ if valid {
+ command := t.replacePlaceholder(a.a, false, string(t.input), list)
+ shell := os.Getenv("SHELL")
+ if len(shell) == 0 {
+ shell = "sh"
+ }
+ shellPath, err := exec.LookPath(shell)
+ if err == nil {
+ t.tui.Close()
+ if t.history != nil {
+ t.history.append(string(t.input))
+ }
+ syscall.Exec(shellPath, []string{shell, "-c", command}, os.Environ())
}
- syscall.Exec(shellPath, []string{shell, "-c", command}, os.Environ())
}
case actExecute, actExecuteSilent:
t.executeCommand(a.a, false, a.t == actExecuteSilent, false)