Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

@(1csh)

alias(1csh)

bg(1csh)

break(1csh)

cd(1sh)

chdir(1sh)

continue(1csh)

csh(1csh)

echo(1csh)

eval(1csh)

exec(1csh)

exit(1csh)

fg(1csh)

glob(1csh)

goto(1csh)

hashstat(1csh)

history(1csh)

jobs(1csh)

kill(1csh)

limit(1csh)

logout(1csh)

nice(1csh)

nohup(1csh)

notify(1csh)

onintr(1csh)

rehash(1csh)

CD(1CSH)

repeat(1csh)

set(1csh)

setenv(1csh)

sh(1sh)

shift(1csh)

source(1csh)

stop(1csh)

suspend(1csh)

time(1csh)

umask(1csh)

unhash(1csh)

unalias(1csh)

unlimit(1csh)

unset(1csh)

unsetenv(1csh)

wait(1csh)

which(1csh)

chdir(2)



CD(1CSH)                COMMAND REFERENCE                CD(1CSH)



NAME
     cd, chdir, pushd, popd, dirs - directory change commands
     (csh built-in)

SYNOPSIS
     cd [ dirname ]
     or
     cd +n
     chdir [ dirname ]
     or
     chdir +n
     pushd [ dirname ]
     or
     pushd +n
     popd [ +n ]
     dirs

DESCRIPTION
     Csh maintains the name current directory and a directory
     stack which can be used to keep up with all of the places
     the user has been and may wish to go back to.  With this,
     the user does not have to remember where to go back to when
     sidetracked.

     The command cd, and its synonym chdir, change the current
     working directory of the shell.  If no argument is given,
     the directory is changed to the user's home directory.  If
     dirname begins with `/', `./', or `../', an attempt is made
     to change to that directory.  Otherwise, the directory
     dirname is searched for in the current directory and in each
     element of the variable cdpath. If this fails, and there is
     a variable named the same as the value of dirname whose
     value begins with a `/', that directory is used (see
     EXAMPLES).  When the directory is changed, the top element
     of the directory stack is replaced by the new directory.
     When the cdpath or directory name variable is used to change
     the directory, the path of the new current directory is
     printed.  With the argument +n, where n is a number
     (beginning at 0), the n'th element of the directory stack is
     moved from that position to the top of the stack.  The
     contents of the directory stack are always printed upon
     completion.

     The command pushd is used to add directory names to the
     directory stack, and to edit the stack, as well as change
     the current directory.  With no arguments, pushd exchanges
     the top two elements of the directory stack.  With a
     directory name argument, the directory is changed, and the
     name of the new current directory is pushed on to the stack.
     With the argument +n, where n is a number (beginning at 0),
     the n'th element of the directory stack is moved from that
     position to the top of the stack.  The contents of the



Printed 4/6/89                                                  1





CD(1CSH)                COMMAND REFERENCE                CD(1CSH)



     directory stack is always printed upon completion.

     The command popd is used to remove elements from the
     directory stack.  With no arguments, the top element of the
     stack is removed, resulting in changing the current working
     directory.  With the argument +n, where n is a number
     (numbers begin at 0, but `+0' is not valid), the n'th
     element of the directory stack is removed.  In the latter
     use, the current directory is unchanged.  The contents of
     the directory stack is always printed upon completion.

     The command dirs prints the contents of the directory stack
     in order.  The top element (which is the current directory)
     is printed first.

     The variable cdpath contains a list of directories to search
     if the directory name given is not a subdirectory of the
     current directory.  This variable is maintained along with
     the environment variable CDPATH, which is used by the
     sh(1sh) cd command, but these variables are not the same.
     In csh, the current directory is implicitly the first
     element in cdpath, whereas in sh, the current directory must
     be given explicitly.  In order to cope with this difference,
     the value of CDPATH is imported upon startup of a new shell.
     CDPATH is changed when cdpath is changed (using set(1csh) ),
     but cdpath is not changed when CDPATH is changed (using
     setenv(1csh) ).

     The variable cwd is set by csh whenever the current
     directory is changed.  Due to symbolic links this variable
     may not always contain correct or desirable data.  If the
     value of cwd is required to be correct, the variable
     hardpaths may be set, which causes all changes of directory
     to get the current directory path by calling getwd(3c),
     which will give the correct path.  This makes directory
     changes somewhat slower.  An alternate method is to use the
     command pwd(1) to get the correct current directory path
     when needed.

EXAMPLES
     This example shows a use of the directory name variable.

          set default=/
          set cdpath=( ~ ~/* )
          cd default

     In this case, if there is no directory named `default' in
     the current directory, the user's home directory, and any
     subdirectories of the user's home directory, the current
     directory will become `/'.





Printed 4/6/89                                                  2





CD(1CSH)                COMMAND REFERENCE                CD(1CSH)



     The following example shows some of the features of
     manipulation of the directory stack.  Here, the character
     `%' represents the csh prompt.

          % dirs
          ~
          % pushd /bin
          /bin ~
          % pushd /etc
          /etc /bin ~
          % cd /usr
          % dirs
          /usr /bin ~
          % pushd +2
          ~ /usr /bin
          % popd +2
          ~ /usr
          % popd
          /usr

VARIABLES
     CDPATH         The directory change search path.

RETURN VALUE
     [NO_ERRS]      Command completed without error.

     [1]            An error of the type described in the error
                    message occurred.

CAVEATS
     Shell scripts should never change to a subdirectory and
     attempt to go back by executing cd .. , since the directory
     changed to may be a symbolic link to another directory whose
     parent directory is different from where the last cd was
     executed.  At the very least, the cwd variable's value
     should be saved and used to go back.  Popd cleans up
     (removes) bad directories in its stack; when popping to the
     next directory, it actually pops to the next valid
     directory, removing all nonexistent directories in-between
     from the stack.  If all the directories on the stack are
     bad, including the curent one, popd tries to change
     directory to the user's HOME directory.  If this also fails,
     it prints another error message and leaves the user in the
     bogus current directory.

SEE ALSO
     @(1csh), alias(1csh), bg(1csh), break(1csh), cd(1sh),
     chdir(1sh), continue(1csh), csh(1csh), echo(1csh),
     eval(1csh), exec(1csh), exit(1csh), fg(1csh), glob(1csh),
     goto(1csh), hashstat(1csh), history(1csh), jobs(1csh),
     kill(1csh), limit(1csh), logout(1csh), nice(1csh),
     nohup(1csh), notify(1csh), onintr(1csh), rehash(1csh),



Printed 4/6/89                                                  3





CD(1CSH)                COMMAND REFERENCE                CD(1CSH)



     repeat(1csh), set(1csh), setenv(1csh), sh(1sh), shift(1csh),
     source(1csh), stop(1csh), suspend(1csh), time(1csh),
     umask(1csh), unhash(1csh), unalias(1csh), unlimit(1csh),
     unset(1csh), unsetenv(1csh), wait(1csh), which(1csh), and
     chdir(2).


















































Printed 4/6/89                                                  4



%%index%%
na:264,158;
sy:422,656;
de:1078,2357;3771,2359;
ex:6130,451;6917,473;
va:7390,155;
rv:7545,280;
ca:7825,1121;
se:8946,873;10155,637;
%%index%%000000000166

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026