diff --git a/pkg/eval/compile_value.go b/pkg/eval/compile_value.go index 8e48be1c..3fc73d73 100644 --- a/pkg/eval/compile_value.go +++ b/pkg/eval/compile_value.go @@ -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 diff --git a/pkg/eval/compile_value_test.go b/pkg/eval/compile_value_test.go index df73610d..3ebe0a37 100644 --- a/pkg/eval/compile_value_test.go +++ b/pkg/eval/compile_value_test.go @@ -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, "~/*"), ) }