mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
pkg/eval: Cover more tilde expansion errors.
This commit is contained in:
parent
6723b9a226
commit
786b679509
|
@ -173,8 +173,8 @@ func doTilde(v any) (any, error) {
|
|||
}
|
||||
_, isSlash := v.Segments[1].(glob.Slash)
|
||||
if isSlash {
|
||||
// ~username or ~username/xxx. Replace the first segment with
|
||||
// the home directory of the specified user.
|
||||
// ~username/xxx. Replace the first segment with the home
|
||||
// directory of the specified user.
|
||||
dir, err := getHome(seg.Data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -92,7 +92,7 @@ func TestTilde(t *testing.T) {
|
|||
case "other":
|
||||
return otherHome, nil
|
||||
default:
|
||||
return "", fmt.Errorf("don't know home of %q", name)
|
||||
return "", fmt.Errorf("don't know home of %v", name)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -109,6 +109,8 @@ func TestTilde(t *testing.T) {
|
|||
// Regression test for #793.
|
||||
That("put ~other/*").Puts(otherHome+"/other1", otherHome+"/other2"),
|
||||
|
||||
That("put ~bad/*").Throws(ErrorWithMessage("don't know home of bad"), "~bad/*"),
|
||||
|
||||
// TODO: This should be a compilation error.
|
||||
That("put ~*").Throws(ErrCannotDetermineUsername, "~*"),
|
||||
)
|
||||
|
@ -121,6 +123,7 @@ func TestTilde_ErrorForCurrentUser(t *testing.T) {
|
|||
Test(t,
|
||||
That("put ~").Throws(err, "~"),
|
||||
That("put ~/foo").Throws(err, "~/foo"),
|
||||
That("put ~/*").Throws(err, "~/*"),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user