Fix case matching literal ?

Fixes #4896.
This commit is contained in:
Fabian Homborg 2018-04-25 23:37:39 +02:00
parent 2fd15e7c6c
commit e598cb235a
3 changed files with 10 additions and 3 deletions

View file

@ -125,6 +125,9 @@ function __fish_git_files
# A " " means it's unmodified.
#
# Be careful about the ordering here!
#
# HACK: To allow this to work both with and without '?' globs
set -l dq '??'
switch "$stat"
case DD AU UD UA DU AA UU
# Unmerged
@ -166,7 +169,7 @@ function __fish_git_files
# For our purposes, we assume this is a staged deletion.
contains -- deleted-staged $argv; or contains -- all-staged $argv
and printf '%s\t%s\n' "$file" $staged_deleted_desc
case '\?\?'
case "$dq" # a literal '??'
# Untracked
contains -- untracked $argv
and printf '%s\t%s\n' "$file" $untracked_desc

View file

@ -68,6 +68,8 @@ function __fish_hg_prompt --description 'Write out the hg prompt'
for line in $repo_status
# Add a character for each file status if we have one
# HACK: To allow this to work both with and without '?' globs
set -l q '?'
switch $line
case 'A '
set -a hg_statuses added
@ -77,7 +79,7 @@ function __fish_hg_prompt --description 'Write out the hg prompt'
set -a hg_statuses copied
case 'D ' ' D'
set -a hg_statuses deleted
case '\? '
case "$dq "
set -a hg_statuses untracked
case 'U*' '*U' 'DD' 'AA'
set -a hg_statuses unmerged

View file

@ -50,6 +50,8 @@ function __terlar_git_prompt --description 'Write out the git prompt'
set staged 1
end
# HACK: To allow matching a literal `??` both with and without `?` globs.
set -l dq '??'
switch $i
case 'A '
set -a gs added
@ -61,7 +63,7 @@ function __terlar_git_prompt --description 'Write out the git prompt'
set -a gs copied
case 'D ' ' D'
set -a gs deleted
case '\?\?'
case "$dq"
set -a gs untracked
case 'U*' '*U' 'DD' 'AA'
set -a gs unmerged