I'm doing some crude code analysis and I've noticed some weird error lines in my output:
cat: rust/library/portable-simd/crates/test_helpers: Is a directory
cat: rust/library/core/tests/iter/adapters: Is a directory
cat: rust/library/core/src/iter/adapters: Is a directory
cat: rust/library/test/src/formatters: Is a directory
cat: rust/library/test/src/helpers: Is a directory
Plain files are selected using -type f
and -print0
is used to avoid exactly this kind of error.
To make a long story short, this happens:
$ find rust/library/core/src/iter/adapters -print0 -type f | hexdump -C | head -n3
00000000 72 75 73 74 2f 6c 69 62 72 61 72 79 2f 63 6f 72 |rust/library/cor|
00000010 65 2f 73 72 63 2f 69 74 65 72 2f 61 64 61 70 74 |e/src/iter/adapt|
00000020 65 72 73 00 72 75 73 74 2f 6c 69 62 72 61 72 79 |ers.rust/library|
Note the first entry - that is a directory!
$ la -d rust/library/core/src/iter/adapters/
drwxr-xr-x 2 user group 4096 Apr 11 01:57 rust/library/core/src/iter/adapters/
To make things extra weird, the line isn't there when omitting -print0
..
$ find rust/library/core/src/iter/adapters -type f | hexdump -C | head -n3
00000000 72 75 73 74 2f 6c 69 62 72 61 72 79 2f 63 6f 72 |rust/library/cor|
00000010 65 2f 73 72 63 2f 69 74 65 72 2f 61 64 61 70 74 |e/src/iter/adapt|
00000020 65 72 73 2f 6d 61 70 2e 72 73 0a 72 75 73 74 2f |ers/map.rs.rust/|
Is that a bug? Looks like it - but it's find. That's like.. well, erm.. well-tested and such... Surely, I'm using it wrong!
My find binary is from the GNU findutils package in Arch Linux.
EDIT: This is most definitely not a bug:
$ podman run --rm -i -v ".:/data" --workdir /data docker.io/cicirello/gnu-on-alpine:latest find rust/library/core/src/iter/adapters -type f -print0 | hexdump -C | head -n3
00000000 72 75 73 74 2f 6c 69 62 72 61 72 79 2f 63 6f 72 |rust/library/cor|
00000010 65 2f 73 72 63 2f 69 74 65 72 2f 61 64 61 70 74 |e/src/iter/adapt|
00000020 65 72 73 2f 6d 61 70 2e 72 73 00 72 75 73 74 2f |ers/map.rs.rust/|
Everything normal. Both in and out of the container, it's find 4.9.0.
You need to swap -print0
and -type f
, since -print0
causes the line to be printed.