ã·ã§ã«(rc)ã¹ã¯ãªãããæ¸ãã¨ãã®Tips
ä»æ¥ã®å ãã¿ã¯ããシェル(bash)スクリプトを書くときのTips ãã
`{command}
ã³ãã³ãç½®æãã³ãã³ããå®è¡ãããã®æ¨æºåºåãå¼æ°ã¨ãã¦èªã¿è¾¼ãã«ã¯ã`{...}ã使ãããã¡ããå ¥ãåãOKã
ããPlan9ã«ã¯basename(1)ã¯ãããã©ãdirname(1)ã¯ãªãã®ãã
<{command}ã>{command}
bashã«ã¯ãªããã©ãzshã ã¨ããã»ã¹ç½®æã¨å¼ã¶ã®ããªï¼ãã³ãã³ãã®åºåããã¡ã¤ã«ã®ããã«æ±ããã¨ãã§ããã
>{...}ãOKãå
é¨çã«ã¯ã³ãã³ãã®æ¨æºå
¥åºåããã¤ãã«ã¤ãªãããã ãã©ã次ã®ä¾ã®ããã«ãéç·å½¢ãªãã¤ãã©ã¤ã³ãä½ããã¨ãã§ããã
cpu% diff <{echo hoge} <{echo boke} 1c1 < hoge --- > boke
diff(1)以å¤ã ã¨join(1)ã¨ãã便å©ããªã
æ°å¤æ¼ç®
rcã«(())ç¸å½ã®æ©è½ã¯ãªããexprã®ä»£ããã«hoc(1)ã使ããhocã¯å°æ°ç¹æ¼ç®ãOKãã¾ãæ¼ç®åã®éã«ã¹ãã¼ã¹ãå ¥ããã®ã¯NGã
cpu% echo `{hoc -e 1.1+2.2} 3.3
ã¡ãªã¿ã«ã
while () {...}
ã¯ç¡éã«ã¼ãã
read
rcã«ã¯readå é¨ã³ãã³ãã¯ãªãã®ã§ãread(1)ã§ä»£æ¿ãããä¼¼ããããªãã¿ãã10のPlan9小技ãã§æ¸ãã¦ãããã©ãPlan9ã«ã¯findãxargsã¯åå¨ããªãããããªæãããªï¼
cpu% du -a |awk '{print $2}' | while (f=`{read}) { echo $f }
UNIXã§rc -- ãããã«ããã¦
UNIXã§ãrcã使ãããã¨ããå ´åãPlan9portãããããã ãã©ãrc shell FAQãçºãã¦ããUNIXã¸ã®ç§»æ¤çãããããã ããªãªã¸ãã«ã®rcãæ¸ããã®ã¯Tom Duffããã ãã©ãByron RakitzisãããUNIXã«ç§»æ¤ãã¦ãããã§ããèå¿ã®ããã404ã¨ã©ã¼ã ãã¨æã£ã¦ããããWebArchive.orgãããµã«ãã¼ã¸ãã¦ãã人ãããããã°ããããMacOS X 10.4ã§ã®åä½ã確èªã
GNU readlineã使ããã¨ããããã§ãã ãã©ãMacOS Xã ã¨linkã«å¤±æãããåæã¨ãã¦ããã©ã¤ãã©ãªãå¤ãããã®ããªï¼ã§ãã代ããã«çµã¿è¾¼ã¿ã®editlineã£ã¦ã®ã使ãããããããã§ååãããconfigureæã«--with-editlineãä»ããå¿ è¦ãããã