I have a directory with the following files and a .git directory, e.g.
.
├── .git
│ ├── branches
│ ├── COMMIT_EDITMSG
│ ├── packed-refs
│ └── refs
├── readme.md
├── server_build.sh
└── tags
If I run GNU find command with the -prune test, find prints the directory which is prune'd:
% find . -name '.git' -prune
./.git
If add another OR option, then the directory which is pruned not longer appears in the output:
% find . -name '.git' -prune -o -name '*.md' -print
./readme.md
In this case, both -name '.git' and -name '*.md' tests must be returning true, it can't be possible that adding another OR test suddenly makes the -name '.git' -prune test untrue.
Is there some implicit switch being added to the first statement?
In other words is find turning
find . -name '.git' -prune
into
find . -name '.git' -prune -print
at run time? and the implicit -print is taken away when the next test when is added?
Why doesn't find print the -prune'd directory when another "-or" test is applied?
find . \( -name '.git' -prune -o -name '*.md' \) -printalso there is some discussion on this inman findjust beforeEXIT STATUS– Sundeep Jul 19 '16 at 06:10find . -name '.git' -pruneprints.gitbecause there is no other action. On the other hand,find . -name '.git' -prune -o -name '*.md' -printis actually equivalent tofind . \( -name '.git' -prune \) -o \( -name '*.md' \) -a -print, and-pruneno longer prints anything since there is another action. – Satō Katsura Jul 19 '16 at 06:23-prunewas an action, and therefore the implicit-printwould not be used here. – the_velour_fog Jul 19 '16 at 06:26-pruneis not a test, it's an action. – Henrik supports the community Jul 19 '16 at 06:42