Created
May 2, 2017 08:17
-
-
Save stknohg/9b57b117481f52bce741a87e7939fb64 to your computer and use it in GitHub Desktop.
PowerShellコンソール上でruby -e を呼ぶあれやこれや
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# これは文字列のエスケープで死ぬ | |
C:\Ruby23-x64\bin\ruby.exe -e 'puts "Hello World!"' | |
# 解析停止記号を使う - これなら死なない | |
C:\Ruby23-x64\bin\ruby.exe --% -e 'puts "Hello World!"' | |
# "をエスケープする - これなら死なない | |
C:\Ruby23-x64\bin\ruby.exe -e 'puts \"Hello World!\"' | |
# 気合で関数を作る - これも死なない | |
function ruby(){ | |
$RubyPath = "C:\Ruby23-x64\bin\ruby.exe" | |
$RawArguments = $MyInvocation.Line.Replace($MyInvocation.MyCommand.Name,"").TrimStart() | |
Invoke-Expression "$RubyPath --% $RawArguments" | |
} | |
ruby -e 'puts "Hello World!"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment