# The editor commands fc and vi's `v` put the temporary file name on a # command line, so a TMPDIR with a space and a `$` in it has to survive # quoting. Unquoted, the editor got a path cut at the space, and fc ran the # original commands again. command -v python3 >/dev/null 2>&1 || exit 77 mkdir -p 'tmp dir$x' cat >ed.sh <<'INS' #!/bin/sh printf 'echo fc-edited\n' >"$1" INS cat >vis.sh <<'INS' #!/bin/sh printf 'echo vi-edited\n' >"$1" INS chmod +x ed.sh vis.sh # The syntax error names the temporary file, whose name has the work # directory and a random suffix in it: fold both, or the .exp could not be # compared. { TMPDIR="$PWD/tmp dir\$x" PS1='$ ' ENV='' HISTFILE='' VISUAL="$PWD/vis.sh" \ python3 "$TESTS/tools/ptydrive.py" "$TSH" -o vi <<'END' send echo hello\r expect hello send fc -e "$PWD/ed.sh"\r expect fc-edited send echo hi\x1bv\r expect vi-edited # An editor command that raises an exception must not leave the file # behind either: `echo (` is a syntax error, raised past the unlink(). send fc -e 'echo ('\r send exit\r END } | sed -e "s|$PWD|WORK|g" -e 's/zash-fc\.[A-Za-z0-9]*/zash-fc.XXXX/' # Neither editor may leave its file behind. ls -A 'tmp dir$x'