Christian Linden writes:
> Hi,
>
> how do I rm -rf on a dir:
There are utility bundles rm_rf(name)
, and rm_rf_depth(name, depth)
in the
standard library.
bundle agent rm_rf(name) # @brief recursively remove `name` to any depth, including base # @depends rm_rf_depth # @param name the file or directory name # # This bundle will remove `name` to any depth, including `name` itself. # # **Example:** # # ```cf3 # methods: # "bye" usebundle => rm_rf("/var/tmp/oldstuff"); # ``` { methods: "rm" usebundle => rm_rf_depth($(name),"inf"); } bundle agent rm_rf_depth(name,depth) # @brief recursively remove `name` to depth `depth`, including base # @depends recurse_with_base tidy all # @param name the file or directory name # @param depth how far to descend # # This bundle will remove `name` to depth `depth`, including `name` itself. # # **Example:** # # ```cf3 # methods: # "bye" usebundle => rm_rf_depth("/var/tmp/oldstuff", "100"); # ``` { classes: "isdir" expression => isdir($(name)); files: isdir:: "$(name)" file_select => all, depth_search => recurse_with_base($(depth)), delete => tidy; "$(name)/." delete => tidy; !isdir:: "$(name)" delete => tidy; }