mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 15:30:40 +08:00
parent
b0e09303a6
commit
ab7af98ded
12
expand.cpp
12
expand.cpp
|
@ -1633,7 +1633,6 @@ static void expand_home_directory(wcstring &input)
|
|||
if (userinfo == NULL)
|
||||
{
|
||||
tilde_error = true;
|
||||
input[0] = L'~';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1641,10 +1640,17 @@ static void expand_home_directory(wcstring &input)
|
|||
}
|
||||
}
|
||||
|
||||
if (! tilde_error)
|
||||
wchar_t *realhome;
|
||||
realhome = wrealpath(home, NULL);
|
||||
|
||||
if (! tilde_error && realhome)
|
||||
{
|
||||
input.replace(input.begin(), input.begin() + tail_idx, home);
|
||||
input.replace(input.begin(), input.begin() + tail_idx, realhome);
|
||||
}
|
||||
else
|
||||
{
|
||||
input[0] = L'~';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,3 +80,15 @@ echo $foo[d]
|
|||
|
||||
echo ()[1]
|
||||
echo ()[d]
|
||||
|
||||
# Test tilde expansion
|
||||
set tmpdir (mktemp -d)
|
||||
mkdir $tmpdir/realhome
|
||||
ln -s $tmpdir/realhome $tmpdir/linkhome
|
||||
set expandedtilde (env HOME=$tmpdir/linkhome ../fish -c 'echo ~')
|
||||
if test $expandedtilde != $tmpdir/realhome
|
||||
echo '~ expands to' $expandedtilde ' - expected ' $tmpdir/realhome
|
||||
end
|
||||
unlink $tmpdir/linkhome
|
||||
rmdir $tmpdir/realhome
|
||||
rmdir $tmpdir
|
||||
|
|
Loading…
Reference in New Issue
Block a user