mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 02:31:18 -03:00
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.
37 lines
887 B
Fish
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)
|