fix: allow absolute paths for the 'dir' command (#3186)

mine
Erich Fussi 2025-03-10 18:28:32 +01:00 committed by GitHub
parent 0320ba387b
commit 1244cc518d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -40,7 +40,13 @@ func newArgs(p *Interpreter, aa []string) args {
}
case strings.Index(a, filterFlag) == 0:
args[filterKey] = strings.ToLower(a[1:])
if p.IsDirCmd() {
if _, ok := args[topicKey]; !ok {
args[topicKey] = a
}
} else {
args[filterKey] = strings.ToLower(a[1:])
}
case strings.Contains(a, labelFlag):
if ll := ToLabels(a); len(ll) != 0 {

View File

@ -242,11 +242,18 @@ func TestDirCmd(t *testing.T) {
"toast-nodir": {
cmd: "dir",
},
"caps": {
cmd: "dir DirName",
ok: true,
dir: "DirName",
},
"abs": {
cmd: "dir /tmp",
ok: true,
dir: "/tmp",
},
}
for k := range uu {