20.8 Removing files and directories

Files removal is forced: the --force option to rm is always used. It is responsibility of the caller to validate the operation before invoking these functions.

Some functions test the existence of the pathname before attempting to remove it: this is done only if test execution is disabled; if test execution is enabled the command line is echoed to stderr to make it easier to debug scripts.

Function: mbfl_file_enable_remove

Declare the commands required to remove files and directories. Declaring the intention to use a program

The programs are: rm, rmdir.

Function: mbfl_file_remove PATHNAME

Remove PATHNAME, no matter if it is a file or directory. If it is a directory: descend the sub-levels removing all of them. If an error occurs return 1.

Function: mbfl_file_remove_file PATHNAME

Remove the file or symbolic link selected by PATHNAME. If the file does not exist or it is not a file or an error occurs: return 1.

Remove the symbolic link selected by PATHNAME. If the link does not exist or it is not a symbolic link or an error occurs: return 1.

Remove the file or symbolic link selected by PATHNAME. If the file does not exist or it is not a file or an error occurs: return 1.

Function: mbfl_file_remove_directory PATHNAME

Remove the directory selected by PATHNAME. If the directory does not exist or an error occurs: return 1.

Function: mbfl_file_remove_directory_silently PATHNAME

Like mbfl_file_remove_directory(), but do not print messages if the directory is not empty.

Function: mbfl_exec_rm ARG

Execute the program rm with the given optional command line arguments.

Function: mbfl_exec_rmdir ARG

Execute the program rmdir with the given optional command line arguments.


This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.