geting the real path

Hi there,
Is there any way to obtain a real path from a weird path. For example :

/foo/../bar/    ->  /bar/
/foo/.          ->  /foo/

Thanks in advance
Santiago

$ bash -c "cd /foo/../bar/ ; pwd"
/bar

Great job ! Thank you
It looks so simple ! I would never have thought about it.
What if we want to clean the path to a file ?

truncate the file from the path with dirname and basename
# dirname /foo/../bar/file
/foo/../bar
# basename /foo/../bar/file
file

clear the path and stick it together again

Great job again thx.
I'm new in this forum. Is there any way to flag my question as "solved".
This feature helps people who search something to select only "solved" threads.

Here is another solution that I just found:

sudo aptitude install realpath
realpath -s /home/../var/./run//motd
/var/run/motd