るりまサーチ

最速Rubyリファレンスマニュアル検索!
22件ヒット [1-22件を表示] (0.104秒)

別のキーワード

  1. _builtin to_h
  2. hash to_h
  3. enumerable to_h
  4. ostruct to_h
  5. struct to_h

ライブラリ

モジュール

検索結果

Shellwords.#shellescape(str) -> String (27208.0)

文字列を Bourne シェルのコマンドライン中で安全に使えるようにエスケープします。

...ープします。

@param str エスケープの対象となる文字列を指定します。
@return エスケープされた文字列を返します。

例:
require 'shellwords'

pattern = 'Jan 15'
puts "grep #{Shellwords.shellescape(pattern)} file"
# => grep Jan\ 15 file...

Shellwords.#shelljoin(array) -> String (9107.0)

配列の各要素である文字列に対して、Bourne シェルのコマンドライン中で安全に 使えるためのエスケープを適用し、空白文字を介してそれらを連結したコマンド ライン文字列を生成します。

...エスケープには、Shellwords.#shellescape
同じ規則が適用されます。

@param array エスケープ対象の文字列を要素とする配列を指定します。
@return エスケープ結果を連結した文字列を返します。

例:
require 'shellwords'

patter...
...n = 'Jan 15'
file = 'file name with spaces'
puts Shellwords.shelljoin(['grep', pattern, file])
# => grep Jan\ 15 file\ name\ with\ spaces...