# Interactive: vi's `v` puts the line in $VISUAL, else $EDITOR. # # The editor here is a script that writes the line it was given back as a # new command, so the test sees that the editor ran and what it was # handed: the line being edited, on its own. # # `v` runs the editor through eval_string() while the outer command is # half parsed, so under `make asan` this is also a regression test for a # nested eval that frees the parse arena (see posix/trap-midtoken). command -v python3 >/dev/null 2>&1 || exit 77 cat >ed.sh <<'INS' #!/bin/sh printf "echo edited '%s'\n" "$(cat "$1")" >"$1" INS cat >vis.sh <<'INS' #!/bin/sh printf "echo visual '%s'\n" "$(cat "$1")" >"$1" INS chmod +x ed.sh vis.sh # $VISUAL wins over $EDITOR, as POSIX says. PS1='$ ' ENV='' HISTFILE='' EDITOR="$PWD/ed.sh" VISUAL="$PWD/vis.sh" \ python3 "$TESTS/tools/ptydrive.py" "$TSH" -o vi <<'END' send echo one\x1bv send \r expect visual echo one send exit\r END # With no $VISUAL, $EDITOR is used. PS1='$ ' ENV='' HISTFILE='' VISUAL='' EDITOR="$PWD/ed.sh" \ python3 "$TESTS/tools/ptydrive.py" "$TSH" -o vi <<'END' send echo two\x1b0wv send \r expect edited echo two send exit\r END # A failed editor leaves the line alone. PS1='$ ' ENV='' HISTFILE='' VISUAL='' EDITOR=false \ python3 "$TESTS/tools/ptydrive.py" "$TSH" -o vi <<'END' send echo keep me\x1bv expect echo keep me send \r expect keep me send exit\r END