Currently I have written a function change_dir() which uses chdir() to change a directory and I want to extend this function to include cd commands additional functionality of following symbolic link or actual paths when its specified with -P and -L option.
I would like to know how this can be achieved using chdir ? For example :
/home/my_shell is a symbolic link
lrwxrwxrwx 1 root root 31 2010-06-13 15:35 my_shell -> /home/hita/shell_new/hita_shell
WITH -P OPTION:
hita@hita-laptop:/home$ pwd
/home
hita@hita-laptop:/home$ cd -P my_shell
hita@hita-laptop:~/shell_new/hita_shell$ pwd
/home/hita/shell_new/hita_shell (CHANGED DIR)
WITH -L OPTION
hita@hita-laptop:/home$ pwd
/home
hita@hita-laptop:/home$ cd -L my_shell
hita@hita-laptop:/home/my_shell$ pwd
/home/my_shell (CHANGED DIR) (If /home/my_shell is passed as input to chdir() it is resolving the contents of symbolic link)
Is there any other function which will resolve the symbolic path as it is and not the contents of the symbolic link?
Thanks