InBuilding paths robustly,A solution is proposed that includes:shopt -s extglob; dir=${dir//+(\/)//}Can someone explain (parse) that for me?  I understand what it's doing, but not how the syntax works.
What does the syntax on this shell command with extglob mean?
shell;scripting
dir=${dir//+(\/)//} is using the ${PARAMETER/PATTERN/STRING} expansion.  Breaking it down in this case (using a syntax reminiscent of Perl's /x regex modifier, not valid Bash syntax):${       # start expansion  dir    # the parameter being expanded  /      # separates parameter from pattern  /      # double slash means replace all instead of replace first  +(\/)  # the pattern we're looking for  /      # separates pattern from replacement  /      # the replacement text}        # end expansionWith extglob enabled, +(PATTERN) means one or more occurrences of PATTERN.  The pattern \/ matches a slash (the backslash is to indicate that this isn't the slash that separates the pattern and the replacement text), so +(\/) matches one or more / characters.