What is the `cd` command?

I wrote code, moving around my computer (OSX 10.11.6) through the command line, as always, and made a typo! (Bum-Bum-BUUUUM!) Instead of typing:

cd USB

I typed

cd USB

Nothing happened, but he did not register as an incorrect command. After carefully studying this, I did some research: I checked the record man. There was no entry. I found the source file ( /usr/bin/Cd) with which Cdand then cated it:

#!/bin/sh
# $FreeBSD: src/usr.bin/alias/generic.sh,v 1.2 2005/10/24 22:32:19 cperciva Exp $
# This file is in the public domain.
builtin `echo ${0##*/} | tr \[:upper:] \[:lower:]` ${1+"$@"}

What is it and why is it here? How does this relate to FreeBSD?

Any help would be awesome, thanks!

+4
source share
3 answers

macOS [1] , :

which Cd which Cd which Cd () .

, , , , , - , .

, globbing ( ):

$ ls "$(which Cd)"*  # could match additional files, but the one of interest is among them
/usr/bin/cd  # true case of the filename

Bash ( macOS) . cd cd ( ).

cd , - .

, cd , ( $PATH), /usr/bin/cd.


/usr/bin/cd script, , , .
(Keith Thompson , , , script ).

Matt , script FreeBSD OSX ( FreeBSD), ( ):

POSIX spec:

, , , , , exec, POSIX.1-2008, , (env, find, nice, nohup, time, xargs).

, : () , ( ), , .

:

alias bg cd command false fc fg getopts jobs kill newgrp pwd read true umask unalias wait

. , .

, , POSIX, cd .

POSIX. , - cd - :

" cd , ." - http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cd.html

, :

, kill , ( ), , PID.

, , , , , , POSIX :

alias bg cd command fc fg getopts jobs read umask unalias

Matt , ; , hash, POSIX, script.


[1] Dave Newton , MacOS HFS + (, , ). Dave , , macOS :
diskutil info / | grep -iq '^\s*Name.*case-sensitive*' && echo "case-SENSITIVE" || echo "case-INsensitive"

+6

?

script , , builtin exec, / $0). script .

OSX , /usr/bin/cd Cd, Cd, Cd Cd / fs path (, /usr/bin/cd) Cd. script, Cd , , , script.

FreeBSD?

FreeBSD, Apple case. Mac ( ).

$FreeBSD: src/usr.bin/alias/generic.sh,v 1.2 2005/10/24 22:32:19 cperciva Exp $ .

OSX FreeBSD . Windowing Cocoa - , OSX Apple. Apple FreeBSD, Clang LLVM .

?

FreeBSD svn :

script, POSIX- `` '' ...

script, script alias bg cd command fc fg getopts hash jobs read type ulimit umask unalias wait. POSIX - !

+2

, MacOS . , /usr/bin/Cd, /usr/bin/Cd, .

,

ls /usr/bin/ | grep -i cd

cd . , . cd , .

, , .

(, bash) . cd, script /usr/bin/Cd, .

+1

Source: https://habr.com/ru/post/1650429/


All Articles