Skip to content
Myr

Run 'become' only when the command template is properly evaluated

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 719dbb8 · Browse files · 2 files+23 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+23 added−15 removed

  • tests:+9 added−3 removed
  • other:+14 added−12 removed

2 files+23 added−15 removed

modified:src/terminal.go+14 added-12 removed
2861 unmodified lines
2862 doAction = func(a *action) bool {2863 switch a.t {2864 case actIgnore:2865 case actBecome:2866 _, list := t.buildPlusList(a.a, false)2867 command := t.replacePlaceholder(a.a, false, string(t.input), list)2868 shell := os.Getenv("SHELL")2869 if len(shell) == 0 {2870 shell = "sh"2871 }2872 shellPath, err := exec.LookPath(shell)2873 if err == nil {2874 t.tui.Close()2875 if t.history != nil {2876 t.history.append(string(t.input))2866 valid, list := t.buildPlusList(a.a, false)2867 if valid {2868 command := t.replacePlaceholder(a.a, false, string(t.input), list)2869 shell := os.Getenv("SHELL")2870 if len(shell) == 0 {2871 shell = "sh"2872 }2873 shellPath, err := exec.LookPath(shell)2874 if err == nil {2875 t.tui.Close()2876 if t.history != nil {2877 t.history.append(string(t.input))2878 }2878 syscall.Exec(shellPath, []string{shell, "-c", command}, os.Environ())2879 syscall.Exec(shellPath, []string{shell, "-c", command}, os.Environ())2880 }2881 }2882 case actExecute, actExecuteSilent:2883 t.executeCommand(a.a, false, a.t == actExecuteSilent, false)2884 case actExecuteMulti:
707 unmodified lines
modified:test/test_go.rb+9 added-3 removed
2643 unmodified lines
2644 tmux.until { |lines| assert_includes lines, '/1/1/' }2645 end26462647 def test_become2648 tmux.send_keys "seq 10 | #{FZF} --bind 'enter:become:seq 100 | #{FZF}'", :Enter2649 tmux.until { |lines| assert_equal 10, lines.item_count }2650 tmux.send_keys :Enter2648 tmux.send_keys "seq 100 | #{FZF} --bind 'enter:become:seq {} | #{FZF}'", :Enter2649 tmux.until { |lines| assert_equal 100, lines.item_count }2650 tmux.send_keys 9992651 tmux.until { |lines| assert_equal 0, lines.match_count }2652 tmux.send_keys :Enter2653 tmux.until { |lines| assert_equal 0, lines.match_count }2654 tmux.send_keys :BSpace2655 tmux.until { |lines| assert_equal 1, lines.match_count }2656 tmux.send_keys :Enter2657 tmux.until { |lines| assert_equal 99, lines.item_count }2658 end2659end26602661module TestShell
482 unmodified lines