The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 02-11-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by usfish View Post
There is an interview question about UNIX bash:

Some shells like bash try to make '..' always work propery, namely, cd ../$USER will place you in your home directory. Does bash always get this behavior correct?

Anyway can provide any example that bash doesnt work well?

"cd ../$USER" will not place you in your home directory unless you are in a directory on the same level as your home directory.

You may be thinking of:

Code:
cd ~user
That will not work with a variable unless you use eval:

Code:
eval "cd ~$USER"
To go to your home directory, use cd with no directory.