Gaucheã§ã·ã§ã«ã¹ã¯ãªããçãªä½ããæ¸ãããã®ããã¢ããã¼ã«æ¸ãã
Gaucheã£ã¦ãã®ã¾ã¾ã ã¨ã·ã§ã«ã¹ã¯ãªããçãªãã®ããã¡ãã£ã¨æ¸ãããããç¨éã«ã¯ããã¾ãåãã¦ãªãã¦ãæ®éã«ã·ã§ã«ã¹ã¯ãªããæ¸ãããruby使ã£ãããã¦ããã ãã©ãããããgaucheã§ããããããããã¨ããæ°åã«ãªã£ã¦ãããç¨éããããã¨ãä¼¼ããããªã©ã¤ãã©ãªã誰ãæ¸ãã¦ãã¦ãããæ°ãããããã©ã調ã¹ãã®ãé¢åãªã®ã§èªåã§æ¸ãã¦ã¿ããã¤ãã§ã«ãã®ã©ã¤ãã©ãªãããã©ã«ãã§å©ç¨ã§ããç¶æ ã«ããä¸ã«ãåæåãã¡ã¤ã«ãèªã¿ããã§goshãèµ·åããgoshellã¨ããã³ãã³ããã¤ãã£ãã
ã¾ããäºã使ãããã·ã§ã«ã®ã³ãã³ãã $HOME/.goshellrc ã«ç»é²ãããã¨ãããã mkdir, ls, wget ããããç»é²ããã¨ãã¯ããããªæãã
(define-commands mkdir ls wget)
ãã¦ãä¾ãã° http://foo.com/[000-999].jpg ã¨ãã1000åã®ãã¡ã¤ã«ã /tmp/foo/ ã¨ãããã£ã¬ã¯ããªã«ä¿åããã¹ã¯ãªãããæ¸ãããã¨ãããããã®å ´åã¯ããããã°ããã
$ goshell ;;; ã¤ã³ã¿ã©ã¯ãã£ãã·ã§ã«èµ·å gosh> (mkdir /tmp/foo) gosh> (dolist (i (iota 1000 0)) (let1 i (string-pad (number->string i) 3 #\0) (wget #`"http://foo.com/,|i|.jpg" -O #`",|i|.jpg")))
ãããã¯ããã¡ã¤ã«ã«ã¹ã¯ãªãããæ¸ãã¦ãOK
#!/usr/local/bin/goshell (mkdir /tmp/foo) (dolist (i (iota 1000 0)) (let1 i (string-pad (number->string i) 3 #\0) (wget "http://foo.com/,|i|.jpg" -O #`"/tmp/foo/,|i|.jpg")))
foo.scmã¨ããååã§ä¿åããã
$ goshell foo.scm
ã§å®è¡ã§ããããããã¯å®è¡å±æ§ãã¤ããã°ããã®ã¾ã¾ã³ãã³ãã¨ãã¦å®è¡ãã§ããã
ãã®ã©ã¤ãã©ãªã®ãã¢ãã¨ããã¯ããã¯ãã使ã£ã¦ã·ã§ã«ã®ã³ãã³ãã«å¯¾å¿ãããã¯ããçæãã¦ãã·ã§ã«ã«ã³ãã³ããæ¸ãæè¦ã§ã³ãã³ããå®è¡ã§ããããã«ããã¨ãããdefine-commandsãã¯ãã使ããã¨ã§ãå¼ã³åºããã³ãã³ããåçã«è¿½å ãããã¨ããã¡ããå¯è½ã
gosh> uname *** ERROR: unbound variable: uname Stack Trace: _______________________________________ gosh> (define-commands uname) #<undef> gosh> (uname -a) ("Linux haya-ubuntu 2.*.**-*-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008 i686 GNU/Linux")