Re: Raku one-liners posted on Unix & Linux StackExchange
[email protected] (Richard Hainsworth) Mon, 26 May 2025 14:50:46 +0100
| Newsgroups | perl.perl6.users |
|---|---|
| Message-ID | <[email protected]> |
On 26/05/2025 12:13, Elizabeth Mattijsen wrote: >> On 26 May 2025, at 00:34, Sean McAfee <[email protected]> wrote: >> >> On Sun, May 25, 2025 at 12:32 PM Sean McAfee <[email protected]> wrote: >> I'll have to play around with your code a bit. Normally I would use `.dir(test => /:i \.pdf / )` to pull out PDF files. >> >> Oh yeah, that's a bit better. I'm not as familiar with the path API as I could be. >> >> ...Huh. I was just messing around with the test parameter to dir and noticed something that seems to be a bug. If you call dir without any parameters, the special directories "." and ".." are not returned, as mentioned on this page. But if you pass a test parameter, those directories are eligible to be returned. For example, dir(:test(/./)) returns ".".IO and "..".IO among its results. >> >> Does anyone know if this is the intended behavior? It doesn't really seem useful. > Afaik it is intended behaviour, as they are specifically being added in the case of the "test" argument. > > https://github.com/rakudo/rakudo/blob/main/src/core.c/Rakudo/Iterator.rakumod#L1524 My understanding is that there is a default test so that '.' and '..' are not returned. So if :test is not specified thats the behaviour you get.