Bug 56700

Summary: Delete task should not follow symlinks by default
Product: Ant Reporter: Trejkaz (pen name) <trejkaz>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Trejkaz (pen name) 2014-07-06 23:22:23 UTC
Our builds always clean the build dir like this:

    <delete dir="build" />

However, I just deleted a couple of my applications, thanks to having a symlink to /Applications and Ant's default behaviour being to follow the symlinks.

I now know that I have to do this to get safe behaviour (added in Bug 22632):

    <delete quiet="true" removeNotFollowedSymlinks="true">
        <fileset dir="build" followsymlinks="false"/>
    </delete>

I know that having the less useful defaults for tasks is something like an Ant culture, but in this particular case, the potential for damage is quite high, so I think that the default behaviour should be the safe behaviour.
Comment 1 Trejkaz (pen name) 2016-04-20 06:54:30 UTC
This workaround of using removeNotFollowedSymlinks="true" doesn't appear to delete symlinks... so I'm not sure there is a real workaround without using <exec>.

Currently we have to use rm directly.

        <exec executable="rm">
            <arg value="-rf"/>
            <arg path="build"/>
        </exec>