20.2.2 Absolute and relative pathnames

Function: mbfl_file_subpathname PATHNAME BASEDIR
Function: mbfl_file_subpathname_var _RV PATHNAME BASEDIR

If PATHNAME is a subdirectory or file under BASEDIR: print to stdout the subpathname portion. Example:

mbfl_file_subpathname /a/b/c /a
-> ./b/c

Both PATHNAME and BASEDIR must be full (normalised) pathnames for this function to work. If PATHNAME is recognised as subpathname of BASEDIR: the return code is zero; else the return code is one.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

mbfl_file_subpathname /a /a       -| ./
mbfl_file_subpathname /a/b/c /a/  -| ./b/c
mbfl_file_subpathname /a/b/c /a   -| ./b/c

mbfl_file_subpathname /a/b/c /d   error→ no match

local _RV
mbfl_file_subpathname_var _RV /a/b/c /a
"$_RV" ⇒ ./b/c
Function: mbfl_file_is_absolute PATHNAME

Return true if the first character in PATHNAME is a slash (/); else return false.

Function: mbfl_file_is_absolute_dirname PATHNAME

Return true if PATHNAME is a directory according to mbfl_file_is_directory() and an absolute pathname according to mbfl_file_is_absolute().

Function: mbfl_file_is_absolute_filename PATHNAME

Return true if PATHNAME is a file according to mbfl_file_is_file() and an absolute pathname according to mbfl_file_is_absolute().

Function: mbfl_file_is_relative PATHNAME

Return true if the first character in PATHNAME is not a slash (/); else return false.

Function: mbfl_file_is_relative_dirname PATHNAME

Return true if PATHNAME is a directory according to mbfl_file_is_directory() and an relative pathname according to mbfl_file_is_relative().

Function: mbfl_file_is_relative_filename PATHNAME

Return true if PATHNAME is a file according to mbfl_file_is_file() and an relative pathname according to mbfl_file_is_relative().


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