[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #56410] find -L doesn't follow symlinks outside the specified searc

From: James Youngman
Subject: [bug #56410] find -L doesn't follow symlinks outside the specified search scope
Date: Wed, 29 May 2019 06:36:43 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36

Follow-up Comment #2, bug #56410 (project findutils):

The -L option affects the way that "find" treats symbolic links.  But it has
no effect on the "file" program run by -exec.   {} expands to the file that
"find" is currently considering, which is in this case is a symbolic link.  
Tests made by find on properties will reflect the properties of the file
pointed to by find, but {} will expand to the name of the symbolic link (and
not its target).

Here is a shell script which I think demonstrates the point you were trying to
make, but without requiring root privileges.


set -u

if ! top="$(mktemp -d)"; then
  echo "Failed to create a temporary directory" >&2
  exit 1

set -eCux
cd "${top}"
mkdir temp temp2
echo "test" >| temp/file0.txt
( cd temp2 && ln -s ../temp/file0.txt file )
if wc -c < temp2/file >/dev/null ; then
  exit 1
find -L temp2/ -type f -exec file '{}' \;
ls -ltR "${top}"
rm -rf "${top}"
exit $rv


Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]