The bash function presented here normalizes path names. By normalize I mean it removes unneeded /./ and ../dir sequences. For example, ../d1/./d2/../f1 normalized would be ../d1/f1.
The first version of the function uses bash regular expressions. The /./ sequences are removed first during variable expansion with substitution by the line: