Files
fish-shell/tests/checks/vcs-prompts.fish
Peter Ammon 17fdd2f153 Clean up "strip control characters" changes
Simplify these and move the sanitization closer to the point of output.

Stop worrying about control characters beyond what PCRE2 reports in
"[[:cntrl:]]" for clarity.
2026-05-25 16:48:30 -07:00

37 lines
887 B
Fish

#RUN: %fish %s
#REQUIRES: command -v git
# Verify VCS prompts strip control characters from
# state files before showing them (same class as prompt_pwd / #12629).
set -l tmp (mktemp -d)
# --- fish_hg_prompt ---
# Stub `hg` to satisfy `command -sq hg` without requiring real Mercurial.
mkdir $tmp/bin
echo '#!/bin/sh' >$tmp/bin/hg
chmod +x $tmp/bin/hg
set -gx PATH $tmp/bin $PATH
mkdir -p $tmp/hgrepo/.hg
touch $tmp/hgrepo/.hg/dirstate
printf 'main\e]0;OHNO\a\x7f' >$tmp/hgrepo/.hg/branch
cd $tmp/hgrepo
fish_hg_prompt
echo
# CHECK: {{.*}} (main]0;OHNO)
# --- fish_git_prompt: rebase-merge state with escape sequence in head-name ---
mkdir $tmp/gitrepo
cd $tmp/gitrepo
git init -q
mkdir .git/rebase-merge
printf 'refs/heads/main\e]0;OHNO\a\x7f' >.git/rebase-merge/head-name
: >.git/rebase-merge/msgnum
: >.git/rebase-merge/end
fish_git_prompt
echo
# CHECK: (main]0;OHNO|REBASE-m)