Listing 3: Example for processing words
GetBaseName() # target full-path
{
if Matches "$2" '*/'
then
eval $1=.
else
SplitSep pathparts "/" $2
GetLastWord $1 $pathparts
fi
}
GetDirName() # target full-path
{
case "$2" in
/*/*)
SplitSep pathparts "/" $2
GetAllButLastWord $1 "/" "" $pathparts
;;
/*)
eval $1='/'
;;
*/*)
SplitSep pathparts "/" $2
GetAllButLastWord $1 "/" $pathparts
;;
*)
eval $1=.
;;
esac
}
# End of File
|