mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 02:31:18 -03:00
Isolate hack for skipping internal separator
stage_wildcards has no need for INTERNAL_SEPARATOR. Remove it already
at this stage, to avoid the need to have the workaround in the generic
decoding routine.
Unfortunately we still can't add assert!(!fish_reserved_codepoint(c));
to wcs2bytes_callback, since builtin printf still passes arbitrary
characters. We should fix that later.
Test that printf now behaves correctly for INTERNAL_SEPARATOR.
Also add a regression test for 0c9b73e317.
This commit is contained in:
@@ -1394,6 +1394,8 @@ fn stage_home_and_self(
|
|||||||
mut input: WString,
|
mut input: WString,
|
||||||
out: &mut CompletionReceiver,
|
out: &mut CompletionReceiver,
|
||||||
) -> ExpandResult {
|
) -> ExpandResult {
|
||||||
|
remove_internal_separator(&mut input, self.flags.contains(ExpandFlags::SKIP_WILDCARDS));
|
||||||
|
|
||||||
expand_home_directory(&mut input, self.ctx.vars());
|
expand_home_directory(&mut input, self.ctx.vars());
|
||||||
if !feature_test(FeatureFlag::RemovePercentSelf) {
|
if !feature_test(FeatureFlag::RemovePercentSelf) {
|
||||||
expand_percent_self(&mut input);
|
expand_percent_self(&mut input);
|
||||||
@@ -1406,15 +1408,11 @@ fn stage_home_and_self(
|
|||||||
|
|
||||||
fn stage_wildcards(
|
fn stage_wildcards(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut path_to_expand: WString,
|
path_to_expand: WString,
|
||||||
out: &mut CompletionReceiver,
|
out: &mut CompletionReceiver,
|
||||||
) -> ExpandResult {
|
) -> ExpandResult {
|
||||||
let mut result = ExpandResult::ok();
|
let mut result = ExpandResult::ok();
|
||||||
|
|
||||||
remove_internal_separator(
|
|
||||||
&mut path_to_expand,
|
|
||||||
self.flags.contains(ExpandFlags::SKIP_WILDCARDS),
|
|
||||||
);
|
|
||||||
let has_wildcard = wildcard_has_internal(&path_to_expand); // e.g. ANY_STRING
|
let has_wildcard = wildcard_has_internal(&path_to_expand); // e.g. ANY_STRING
|
||||||
let for_completions = self.flags.contains(ExpandFlags::FOR_COMPLETIONS);
|
let for_completions = self.flags.contains(ExpandFlags::FOR_COMPLETIONS);
|
||||||
let skip_wildcards = self.flags.contains(ExpandFlags::SKIP_WILDCARDS);
|
let skip_wildcards = self.flags.contains(ExpandFlags::SKIP_WILDCARDS);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
//! Helper functions for working with wcstring.
|
//! Helper functions for working with wcstring.
|
||||||
|
|
||||||
use crate::common::{get_ellipsis_char, get_ellipsis_str};
|
use crate::common::{get_ellipsis_char, get_ellipsis_str};
|
||||||
use crate::expand::INTERNAL_SEPARATOR;
|
|
||||||
use crate::fallback::{fish_wcwidth, wcscasecmp, wcscasecmp_fuzzy};
|
use crate::fallback::{fish_wcwidth, wcscasecmp, wcscasecmp_fuzzy};
|
||||||
use crate::wchar::{decode_byte_from_char, prelude::*};
|
use crate::wchar::{decode_byte_from_char, prelude::*};
|
||||||
|
|
||||||
@@ -322,11 +321,6 @@ pub fn wcs2bytes_callback(input: &wstr, mut func: impl FnMut(&[u8]) -> bool) ->
|
|||||||
let mut converted = [0_u8; 4];
|
let mut converted = [0_u8; 4];
|
||||||
|
|
||||||
for c in input.chars() {
|
for c in input.chars() {
|
||||||
if c == INTERNAL_SEPARATOR {
|
|
||||||
// do nothing, this is important for ~$user handling
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let bytes = if let Some(byte) = decode_byte_from_char(c) {
|
let bytes = if let Some(byte) = decode_byte_from_char(c) {
|
||||||
converted[0] = byte;
|
converted[0] = byte;
|
||||||
&converted[..=0]
|
&converted[..=0]
|
||||||
|
|||||||
@@ -630,6 +630,9 @@ $fish -c 'echo \ufdd2"fart"'
|
|||||||
echo (printf '\ufdd2foo') | string escape
|
echo (printf '\ufdd2foo') | string escape
|
||||||
# CHECK: \Xef\Xb7\X92foo
|
# CHECK: \Xef\Xb7\X92foo
|
||||||
|
|
||||||
|
echo (printf '\ufdd8foo') | string escape
|
||||||
|
# CHECK: \Xef\Xb7\X98foo
|
||||||
|
|
||||||
printf '%s\n' "#!/bin/sh" 'echo $0' > $tmpdir/argv0.sh
|
printf '%s\n' "#!/bin/sh" 'echo $0' > $tmpdir/argv0.sh
|
||||||
chmod +x $tmpdir/argv0.sh
|
chmod +x $tmpdir/argv0.sh
|
||||||
cd $tmpdir
|
cd $tmpdir
|
||||||
|
|||||||
@@ -350,3 +350,17 @@ echo {asdf,~}
|
|||||||
# CHECK: asdf /{{.*}}
|
# CHECK: asdf /{{.*}}
|
||||||
echo {~}
|
echo {~}
|
||||||
# CHECK: {~}
|
# CHECK: {~}
|
||||||
|
|
||||||
|
function compare
|
||||||
|
test $argv[1] = $argv[2]
|
||||||
|
or begin
|
||||||
|
echo unexpected expansion result:
|
||||||
|
echo expected: $argv[1]
|
||||||
|
echo actual: $argv[2]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if string match -rq -- '^[\w.-]+$' $USER
|
||||||
|
set -l user_home "$(eval "echo ~$USER")"
|
||||||
|
compare $user_home "$(echo ~$USER)"
|
||||||
|
compare $user_home "$(echo ~(printf %s $USER))"
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user