ãWindowsã§ã¯ã.batãã¨ããæ¡å¼µåã®ãã¡ã¤ã«ãä½æãããã¨ã§ãããã«ã¯ãªãã¯ããã ãã§ã³ãã³ãããã³ããã®å¦çãå®è¡ãããã¨ãã§ãããããããããããã¡ã¤ã«ããä½æãããã¨ãã§ãã¾ãã
ãMacOSã§ãããããæ©è½ãããã®ãã¨æã£ã¦èª¿ã¹ã¦ã¿ãããshellãã¡ã¤ã«ãããã«ã¯ãªãã¯ããã ãã§èµ·åããããããã¨ãããã£ãã®ã§ãã®åå¿é²ã§ãã
ãã§ã¯å§ãã¾ãã
ï¼ï¼.commandãã¡ã¤ã«
ãMacOSã§ã¯shellã使ãã¾ãããã®shellã§è¨è¿°ãããã¡ã¤ã«ã®æ¡å¼µåãã.commandãã«å¤æ´ããã¨ãããã«ã¯ãªãã¯ããã ãã§å®è¡ãããã¨ãã§ãã¾ãã
ãä¾ãã°ä»¥ä¸ã®ãããªã³ã¼ããè¨è¿°ãã¦ã¿ã¾ãã
ã»test.command
#!/bin/bash DIR_NAME="test" echo $DIR_NAME mkdir $DIR_NAME # ã«ã¼ããã£ã¬ã¯ããªã«ä½æ
ãä¸è¨ãã¡ã¤ã«ãä½æãã¦ãtest.commandããããã«ã¯ãªãã¯ããã¨èªåã§ã¿ã¼ããã«ãç«ã¡ä¸ããå®è¡ãããtestãã£ã¬ã¯ããªãä½æããã¾ãã
ããã ããã®ã.commandããã¡ã¤ã«ãå®è¡ãããã®ã¯ãã«ã¼ããã£ã¬ã¯ããªããªã®ã§ãã¡ã¤ã«ãåå¨ããã«ã¬ã³ããã£ã¬ã¯ããªã§å®è¡ãããã«ã¯ãcd `dirname $0`ãã®è¨è¿°ã追å ãã¾ãã
ã»test2.command
#!/bin/bash cd `dirname $0` # ã«ã¬ã³ããã£ã¬ã¯ããªã«ç§»å DIR_NAME="test" echo $DIR_NAME mkdir $DIR_NAME # ã«ã¬ã³ããã£ã¬ã¯ããªã«ä½æ
ï¼ï¼å®è¡æ¨©éããªãå ´å
ãã¨ãã£ã¿ãªã©ã§.commandãã¡ã¤ã«ãä½æããå ´åã«æ¨©éããªãã¦å®è¡ã§ããªãå ´åãããã¾ãã
ããã®å ´åã¯ä»¥ä¸ã®ã³ãã³ãã§å®è¡æ¨©éãä»ä¸ããå¿ è¦ãããã¾ãã
chmod u+x [ãã¡ã¤ã«ãã¹]
ï¼ï¼.commandãã¡ã¤ã«å®è¡å¾ã«ã¿ã¼ããã«ãçµäºããããå ´å
ã.commandãã¡ã¤ã«ãå®è¡ãã¦ãã¿ã¼ããã«ã¦ã£ã³ãã¦ã¯èªåçã«éãã¦ããã¾ããã
ãèªåçã«ã¿ã¼ããã«ãçµäºãã¦æ¬²ããå ´åã¯ã¿ã¼ããã«å´ã®è¨å®ãå¤æ´ããå¿ è¦ãããã¾ãã
ãè¨å®ãå¤æ´ããã«ã¯ãã¿ã¼ããã«ãâãç°å¢è¨å®ããé¸æãã¾ãã
ããããã¡ã¤ã«ãâãã·ã§ã«ãã¿ãâãã·ã§ã«çµäºæãã®ãã«ãã¦ã³ãããã·ã§ã«ãæ£å¸¸ã«çµäºããå ´åã¯éããããé¸æãã¾ãã
ãããã§ã¿ã¼ããã«ã¦ã£ã³ãã¦ãèªåçã«éãã¦ãããããã«ãªãã¾ãã
ã以ä¸ãMacOSã§ããããã¡ã¤ã«ãä½æããæ¹æ³ã§ãã
ãå人çã«ãã¾ãããããã¡ã¤ã«ãä½ããã¨ã¯ãªãã®ã§ãããè¦ãã¦ããã¨ã¡ãã£ã¨ãããã¼ã«ãä½ãæã«ä¾¿å©ã ã¨æãã¾ãã
ã»åèè³æ