If this command really exists and works
Um, yes, it exists and works.
If it has the same functionality (change directory)
Yes; yes it does. That’s not to say that someone could not simply create a program (e.g., cd.exe
) that does something else, but it is usually a command built into the shell and changes the current directory.
If there are any problems with its use
What kind of problems? Other than .
and ..
, its syntax is quite straight forward. The only complication is when changing the current directory on other volumes (drive letters). Also, the command-extensions in Windows extend its usage slightly, but nothing that would cause any real problems.
If in any OS there is another command-line command that does the same in a better/more elaborate/more frequetly used way.
Not really. There can be other commands, but cd
is nice and short and does the trick. Other than changing the current drive in addition to the directory, (e.g., cd /d t:\blah
), how exactly could changing the current directory be improved?
This isn’t quite on-topic (though it is related), but apparently some people can’t seem to accept that the CD
command does not have to be built into the shell. The fact is that it does not; it can be an external program. Some operating systems make it easy, others make it difficult, and some may even make it impossible, but the fact is that it can be external and does not always have to be built in as some would have you believe. For example, on 32-bit versions of Windows including XP and 7, you can make use of the fact that the console subsystem (which is how text-mode programs are supported and run in Windows) supports the old “DOS” interrupt 0x21—yes, even in cmd
, not just `command. (It will not work in 64-bit versions of Windows because they dropped a lot of backward-compatibility.)
For example, you can save the debug script below as c.scr
and compile it by running debug < c.scr
from the command-line. It will create a .com
file which you can use to change the current directory.
a
mov si,82
mov dl,[si]
or dl,20
sub dl,61
mov ah,e
int 21
mov dl,[si]
cmp dl,d
jz 119
inc si
jmp 10f
xor dl,dl
mov [si],dl
mov dx,82
mov ah,3b
int 21
mov ah,4c
int 21
n c.com
rcx
28
w
q
(Note, it does not support long filenames, so you will need to use the 8.3 version. It changes the current drive as well, so you can change the directory to another drive in one move, but it does this in a very simple manner and does not do any error-checking, so trying to change to a directory which starts with a letter for which a drive exists will not work. That is, c c:\windows
will work as will c \windows
, but c asd
will not if you have an A:
drive unless it happens to contain a directory named asd
. You can extend it and add error-checking and such if you like, but it proves my point about the possibility of cd
being external in Windows.)
You can also save the following Pascal program (e.g., as c.pas
) and compile it with Turbo Pascal or the GO32 version of the FreePascal compiler (the 32-bit version won’t work because it uses the normal Windows API):
program cd;
begin
chdir(paramstr(1));
end.
Again, just run it to change the current directory (e.g., `c.exe "c:\program files"—yes, long foldernames will work, but will be automatically converted to 8.3 names upon execution).
SET DEFAULT
instead.