title: How to implement your own cd command in your own shell
body: <p>I am working in a mini project: "MY OWN COMMAND INTERPRETER (SHELL)", like the Bash shell or Sh shell. Till now it can execute every predefined commands like ls, ps, pwd, date. Except this I have implemented some other operations like Input Redirection(&lt;), output redirection(>), PIPE (|) features. Along with this i have implemented my own user-commands like pid, ppid, quit, hist.</p>
  
  <pre><code>vvdnlt208@vvdnlt208-Vostro-3446:~/project/Vector/sourabh/unix/proj2$ ./my_sh  
  &lt;1 SOURABH&gt; ls
   a     cd.c       execute.o  inredir.c  main.o   multiexec.o  my_sh   sh.c                sigign.c  test.c
  addhist.c  dir        header.h   inredir.o  Makefile     mypipe.c     outredir.c  showhist.c  sigign.o  tetest.c
  addhist.o  execute.c  inredir    main.c     multiexec.c  mypipe.o     outredir.o    showhist.o  test2.c
  &lt;2 SOURABH&gt; ps
  PID TTY          TIME CMD
  6120 pts/10   00:00:01 bash
  6510 pts/10   00:00:00 grep
  6512 pts/10   00:00:00 grep
  6514 pts/10   00:00:00 grep
  6516 pts/10   00:00:00 grep
  7772 pts/10   00:00:00 my_sh
  7774 pts/10   00:00:00 ps
  &lt;3 SOURABH&gt; pwd
  /home/vvdnlt208/project/Vector/sourabh/unix/proj2
  &lt;4 SOURABH&gt; date
  Fri Nov 14 16:44:24 IST 2014
  &lt;5 SOURABH&gt; 
  &lt;6 SOURABH&gt; 
  &lt;7 SOURABH&gt; 
  &lt;8 SOURABH&gt; hist
  1 ls
  2 ps
  3 pwd
  4 date
  8 hist
  &lt;9 SOURABH&gt; ls &gt;a.txt
  &lt;10 SOURABH&gt; pid
  7772
  &lt;11 SOURABH&gt; ppid
  </code></pre>
  
  <p>But I am facing some difficulty in executing the cd command... </p>
  
  <pre><code>&lt;12 SOURABH&gt; cd
  cd: No such file or directory
  &lt;13 SOURABH&gt; cd dir
  cd: No such file or directory
  &lt;14 SOURABH&gt; 
  </code></pre>
  
  <p>Someone told me to implement it by my own... Please help me in doing this. Thanks in advance.</p>