shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

SC2227 should only apply when there is an additional command

Open srcshelton opened this issue 9 months ago • 0 comments

https://www.shellcheck.net/wiki/SC2227 states:

Redirection applies to the find command itself. Rewrite to work per action (or move to end).

Problematic code: find . -name '*.ppm' -exec pnmtopng {} > {}.png ;

… but this warning triggers even with a command such as:

find "${log}" 2>/dev/null \                               
    -mindepth 4 \                                      
    -maxdepth 5 \                                      
    -name 'build.log' -or -name 'config.log' \         
    -type f \                                          
    -print

… where, since there is no additional command being executed, there doesn't appear to be any such ambiguity?

srcshelton avatar Feb 17 '25 16:02 srcshelton