シェルの文字列エスケープを行うモジュールが用意されている事を知らなかったのでメモ。
require 'shellwords'
p Shellwords.shellsplit('ls -al *').map{|s| Shellwords.shellescape(s) }
# => ["ls", "-al", "\\*"]
More than 5 years have passed since last update.
シェルの文字列エスケープを行うモジュールが用意されている事を知らなかったのでメモ。
require 'shellwords'
p Shellwords.shellsplit('ls -al *').map{|s| Shellwords.shellescape(s) }
# => ["ls", "-al", "\\*"]
Register as a new user and use Qiita more conveniently