On 05/06/2019 21:16, Jefferson Carpenter wrote:
Not quite - if basename begins with one or more slashes that could still cause incorrect behavior.The closest would be echo ${dirname%/}/${basename##*(/)} with the bash extglob option enabled.
Assuming this is the correct behaviour when basename is an absolute path (which as mentioned is questionable), this is doable with just POSIX sh:
${dirname%/}/${basename#"${basename%%[!/]*}"}
Cheers,
Harald van Dijk
