Also known as CHDIR(), change directory, A Quick Introduction to Unix/Changing Directories
command of Unix, DOS, OS/2, AmigaOS, Windows, and Linux operating systems
via Wikipedia infobox
5. Starting with the first pathname in the -separated pathnames of CDPATH (see the ENVIRONMENT VARIABLES section) if the pathname is non-null, test if the concatenation of that pathname, a character if that pathname did not end with a character, and the directory operand names a directory. If the pathname is null, test if the concatenation of dot, a character, and the operand names a directory. In either case, if the resulting string names an existing directory, set curpath to that string and proceed to step 7. Otherwise, repeat this step with the next pathname in CDPATH until all pathnames have been tested. 1. Dot components and any characters that separate them from the next component shall be deleted. 2. The preceding component, all characters separating the preceding component from dot-dot, dot-dot, and all characters separating dot-dot from the following component (if any) shall be deleted. 9. If curpath is longer than {PATH MAX} bytes (including the terminating null) and the directory operand was not longer than {PATH MAX} bytes (including the terminating null), then curpath shall be converted from an absolute pathname to an equivalent relative pathname if possible. This conversion shall always be considered possible if the value of PWD, with a trailing added if it does not already have one, is an initial substring of curpath . Whether or not it is considered possible under other circumstances is unspecified. Implementations may also apply this conversion if curpath is not longer than {PATH MAX} bytes or the directory operand was longer than {PATH MAX} bytes. If, during the execution of the above steps, the PWD environment variable is set, the OLDPWD environment variable shall also be set to the value of the old working directory (that is the current working directory immediately prior to the call to cd ). Handle the operand dot-dot logically; symbolic link components shall not be resolved before dot-dot components are processed (see steps 8. and 9. in the DESCRIPTION). Handle the operand dot-dot physically; symbolic link components shall be resolved before dot-dot components are processed (see step 7. in the DESCRIPTION). which changes to the previous working directory and then writes its name. The name of the directory, used when no directory operand is specified. Provide a default value for the internationalization variables that are unset or null. (See XBD Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) If set to a non-empty string value, override the values of all the other internationalization variables. Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. [XSI) ] ![[Option Start]]( Determine the location of message catalogs for the processing of LC MESSAGES. ![[Option End]]( The use of the CDPATH was introduced in the System V shell. Its use is analogous to the use of the PATH variable in the shell. The BSD C shell used a shell parameter cdpath for this purpose. This behavior is now the default. It is not consistent with the definition of dot-dot in most historical practice; that is, while this behavior has been optionally available in the KornShell, other shells have historically not supported this functionality. The logical pathname is stored in the PWD environment variable when the cd utility completes and this value is used to construct the next directory name if cd is invoked with the -L option. The -L and -P options are added to align with the IEEE P1003.2b draft standard. This also includes the introduction of a new description to include the effect of these options. IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/14 is applied, changing the SYNOPSIS to make it clear that the -L and -P options are mutually-exclusive. Austin Group Interpretation 1003.1-2001 199 is applied, clarifying how the cd utility handles concatenation of two pa
~8 min read
cd is a shell command that changes the working directory. It is available in many shells and other applications that maintain a working directory. In some contexts, the command can perform actions other than change directory. Some environments provide the change directory feature via a different command name such as chdir.
Implementations
Excerpt from a page describing this subject · 15,734 chars · not written by Vinony
via Wikidata · CC0
via Wikidata sitelinks · CC0
Discovered by embedding cosine similarity (sentence-transformers MiniLM, 384-dim).