basename and dirname are programs – read process creation. Shell substitution can be much quicker and far more obscure.
basename is ${ARG##*/}
dollar-leftcurlybrace-A-R-G-sharp-sharp-asterisk-slash-rightcurlybrace
dirname is ${ARG%/*}
dollar-leftcurlybrace-A-R-G-percent-slash-asterisk-rightcurlybrace