Cygwinã§Minttyã使ãå§ãã¦åå¹´ããã¡ã¾ããï¼Minttyã ã¨å ¨ã¦ãUTF-8ç°å¢ã«ãªãã¾ãï¼UTF-8ç°å¢ã ã¨Linuxãµã¼ãã¼ã®SSHã¨ç¸æ§ãããSambaãçµç±ããªãã¦ãæåã³ã¼ãã«æ©ããã¨ãªãå¿«é©ã«æåãç·¨éã§ãã¾ããï¼
mintty + utf8ããã¸ãããã
mintty ã¯ã¨ã¦ã使ããããCUIã§ãWindowsã§ä¸çªä¾¿å©ãªã®ã§ã¯ãªãã§ããããï¼poderosa/putty/ã³ãã³ãããã³ããã»ã»ã»etc ã¤ãã¤ã試ãã¾ãããï¼Minttyã«ãªã£ã¦ããã¨ã¦ãå¿«é©ã«ãªãã¾ããï¼
pingæååããå°ãã¾ããï¼
Windowsã®ping.exeã¯åºåã cp932ã§åºãã¾ããminttyï¼Bashã¯UTF8ã§çµ±ä¸ãåãã¾ãï¼
解決ç㯠nkf ãªã©ã«ããããã¨ã§ããï¼ãã£ã¨è¯ã解決æ¹æ³ãããã¾ãï¼ã³ãã³ãã©ããã¼ãä½ãäºã§ã
æååãããªãPingãä½ãâping.exeã®ã©ããã¼ãä½ã
ping ã³ãã³ããWrapperã§æåã³ã¼ã対å¿ãã¦ãã¾ãã®ã楽ã¡ãã§ããã·ã¼ã ã¬ã¹ã§ã
/usr/local/bin/ping
#!/usr/bin/env ruby KCODE='u' require "kconv" cmd = File.basename(__FILE__) +".exe " + $*.join(' ') IO.foreach("| #{cmd} 2>&1 "){|line|puts line.kconv(Kconv::UTF8,Kconv::SJIS)}
ãã®ãããªã©ããã¼ãæ¸ãã¾ãããä¸äºè§£æ±ºã§ãï¼
ipconfig ãåãããã
å ã»ã©ã® ping ãã³ãã¼ããã°è§£æ±ºã§ã
cp /usr/local/bin/ping /usr/local/bin/ipconfig
ifconfing ãè¯ããã ãã©
Windowsã®ã³ãã³ãã¨ã³ãã³ãåãå¤ããã¨ãã¯ãFile.basename(__FILE__)åºæ¥ãªãã®ã§ãç´æ¸ããã¾ãï¼
#!/usr/bin/env ruby KCODE='u' require "kconv" cmd = "ipconfig.exe " + $*.join(' ') IO.foreach("| #{cmd} 2>&1 "){|line|puts line.kconv(Kconv::UTF8,Kconv::SJIS)}
nslookupãããã
ãã¡ã¤ã³åã調ã¹ããã§ãï¼Cygwinã«ã¯ã³ãã³ãããªãã®ã§ï¼ã©ããã¼ã§å¯¾å¿ãã¾ã
cp /usr/local/bin/ping /usr/local/bin/nslookup
arp ãã¿ãã
åãã§ãï¼ã©ããã¼ã§å¯¾å¿ã§ãã¾ã
cp /usr/local/bin/ping /usr/local/bin/arp
getmacãããã
åãã§ãï¼ã©ããã¼ã§å¯¾å¿ã§ãã¾ã
cp /usr/local/bin/ping /usr/local/bin/getmac
cscript.exeãã¤ãããã
cscript.exeã®ããã«å¼æ°ã«ãã¡ã¤ã«åãåãã¢ãã¯ãã£ããã§ãï¼Cygwinã®UNIXãã¹åã解éã§ããªãã§ãããããå¼æ°ã®ãã¹åãWindowsãã¹åã«å¤ãã¦èµ·åãã¾ãï¼
/usr/local/bin/cscript
#!/usr/bin/env bash function cygpath_to_winpath(){ args=() for i in $@ ; do if [ -s $i ]; then args=(${args[@]} `cygpath -w $i`) else args=(${args[@]} $i) fi done echo ${args[@]} return 0 } cscript.exe `cygpath_to_winpath $@` | nkf -w
python ã ruby (mswin) ã®ããã«shebang ã§ä½¿ãããã³ãã³ãã®å ´å
ruby(win32) ã®gem ã³ãã³ãã®ããã«ãshebang ã§ä½¿ãããã³ãã³ãã®å ´åãé æ ®ãå¿ è¦ã§ã
/usr/local/bin/ruby ããC:/Ruby/bin/ruby ã®ä»£ç¨ã¨ãã¦ä½¿ããshebangã§ä½¿ãããã®ã§ãshebang ã§æ¸¡ãããCygwinã®Pathãå¤æãã¦æ¸¡ãå¿ è¦ãããã
/usr/local/bin/ruby
#!/bin/env bash args=("$@") argn=$# ## å¼æ°ã§ãã¡ã¤ã«ãã¹ã«ãªããã®ã¯å ¨é¨Windowsãã¹ã«å¤æãã for i in $( seq $argn ) do #echo $i; v=${args[$i-1]} #echo $v if [ -e $v ]; then #echo $v exists v=`cygpath -ma $v` args[$i-1]=$v fi #echo ${args[$i-1]} done /cygdrive/c/Ruby/bin/ruby ${args[@]}
ãªã©ã¨ã¨ãã
cygwin ãUTF-8/SJISã§åæ¿ãã¦ä½¿ããã§ã
utf-8ã®Cygwinã¨ã³ãã³ãããã³ããã®SJISã両æ¹ä½¿ãã¨ããç°å¢å¤æ°ãã¿ã¦åºåæåã³ã¼ãã«å¤æããã©ããã¼ã«ãã¦ã¿ãã
/usr/local/bin/route
1 #!/usr/bin/env ruby 2 require "kconv" 3 require "stringio" 4 $stderr = StringIO.new 5 6 $*.unshift "print" if $*.size < 1 7 out_kcode = Kconv::UTF8 8 out_kcode = Kconv::UTF8 if "utf-8"== ENV["LANG"].split(".").last.downcase 9 out_kcode = Kconv::SJIS if "sjis" == ENV["LANG"].split(".").last.downcase 10 IO.foreach("|#{File.basename($0)}.exe #{$*.join(' ')}"){|line|puts line.kconv(out_kcode,Kconv::SJIS)} 11
winçPHP使ãï¼ç©ºç½ãå«ããã¹)
cygwinçã®php ã¯å¾®å¦ãªã®ã§ windowsçã®PHPã使ã
1 #!/usr/bin/env ruby 2 require "kconv" 3 require "stringio" 4 $stderr = StringIO.new 5 out_kcode = Kconv::UTF8 6 out_kcode = Kconv::UTF8 if "utf-8"== ENV["LANG"].split(".").last.downcase 7 out_kcode = Kconv::SJIS if "sjis" == ENV["LANG"].split(".").last.downcase 8 $*.map!{|e| unless e =~ /^\-/ then %!'#{e}'! else e end } 9 IO.foreach("|/home/Public/apps/php/php.exe #{$*.join(' ')}") {|line|puts line.kconv(out_kcode,Kconv::SJIS)}
php ã®å ´å document and settings ã¨ãã¡ãã£ã¨ããããã空ç½ãå«ããã¡ã¤ã«åã«ã¢ã¯ã»ã¹ã«ã®ã§ã¯ã©ã¼ããæãå¦çãå ãã