ã³ãã³ãã®åå¨ã調ã¹ãã¨ãã¯whichããtypeã®æ¹ããã
ãã®è¨äºã¯Imaizumi Lab Advent Calendarã®13æ¥ç®ã§ãã
TL;DR
whichã§åºã¦ãããã¹ã®å®è¡ãã¡ã¤ã«ãå®è¡ããã¦ããã¨ã¯éããªã
詳ããã¿ã
â»ç§ã¯fishã使ã£ã¦ãã¾ããtypeã³ãã³ãã®-sãªãã·ã§ã³ã¯ãªãã·ã§ã«ãããã¾ãã
æ®éã®ã³ãã³ãã®å ´å
$ type -s brew brew is /usr/local/bin/brew $ which brew /usr/local/bin/brew
ä¸è´ãã¾ããã
ãã«ãã¤ã³ã³ãã³ãã®å ´å
$ type -s source source is a builtin $ which source (ä½ã表示ãããªã)
ãã«ãã¤ã³ã³ãã³ãã¨ãããã¨ãç¥ããã«å®è¡ãã¦ãã¾ãã¨ãã³ãã³ãããªãï¼ãã¨ç¦ããã¨ã«ãªãããã§ãã
typeã¨whichã§è¡¨ç¤ºãç°ãªãå ´å
$ type -s cd cd is a function (defined in /usr/local/Cellar/fish/3.1.2/share/fish/functions/cd.fish) $ which cd /usr/bin/cd
typeã¨whichã§çµæãç°ãªã£ã¦ãã¾ããå®éã«ã¯typeã§è¡¨ç¤ºããããã¹ã®ã³ãã³ãã®æ¹ãèªã¿è¾¼ã¾ãã¦ãã¾ãã
typeã¨whichã®çµæãç°ãªãçç±
ããããwhichã¨ã¯ãPATHã«è¨å®ããã¦ãããã£ã¬ã¯ããªãé çªã«èª¿ã¹ã¦æåã«è¦ã¤ãã£ãå®è¡ãã¡ã¤ã«ã表示ããã³ãã³ãã§ãã(ãªãã·ã§ã³ãªãã®å®è¡æ)
å®éã«å®è¡ãããã³ãã³ãã®ãã¹ã¨ã¯éããªãã®ã§ãã
ãã«ãã¤ã³ã³ãã³ãã§ããcdãechoãªã©ã¯ãå®è¡ãã¡ã¤ã«ã/binã/usr/binä¸ã«ãåå¨ãããã¨ãããããããã£ãã±ã¼ã¹ã§whichã使ãã¨å®éã«å®è¡ãããã³ãã³ãã®ãã¹ã¨åºã¦ãããã¹ãç°ãªã£ã¦ãã¾ãã¾ãã*1
(2020/12/19追è¨) Macã®å ´åã§ããã/binã/usr/binä¸ã«ãããã«ãã¤ã³ã³ãã³ãã¨ååã®ã³ãã³ãã®ä¸èº«ã¯builtin(ãã«ãã¤ã³ã³ãã³ããåªå å®è¡ããã³ãã³ã)ã®ããã§ããçµå±ã®ã¨ãããã«ãã¤ã³ã³ãã³ããå®è¡ããã¦ããããã§ãã
å°ããããªã±ã¼ã¹ã¨ãã¦ã¯ããã«ãã¤ã³ã³ãã³ãã¨ååã®ã³ãã³ããä½æãã¦/binä¸ã«ç½®ãã¦ããæã¨ãã§ããããã
æãã¬ããããã¤ã³ãã«ãªããããªãã®ã§ããªãã¹ãtypeã使ã£ãæ¹ãããã¨æãã¾ãã
*1:ãã«ãã¤ã³ã³ãã³ããªã®ã§ã³ãã³ãã®ãã¹ã¨ããè¨ãæ¹ãé©åãªã®ãã©ããã¯...