diff options
Diffstat (limited to 'libexec/erb')
| -rwxr-xr-x | libexec/erb | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/libexec/erb b/libexec/erb index ded76991dc..de7d5888c3 100755 --- a/libexec/erb +++ b/libexec/erb @@ -74,11 +74,6 @@ class ERB $DEBUG = true when '-r' # require require ARGV.req_arg - when '-S' # security level - warn 'warning: -S option of erb command is deprecated. Please do not use this.' - arg = ARGV.req_arg - raise "invalid safe_level #{arg.dump}" unless arg =~ /\A[0-1]\z/ - safe_level = arg.to_i when '-T' # trim mode arg = ARGV.req_arg if arg == '-' @@ -95,29 +90,49 @@ class ERB when '-P' disable_percent = true when '--help' - raise "print this help" + raise '' when /\A-/ - raise "unknown switch #{switch.dump}" + raise "Unknown switch: #{switch.dump}" else var, val = *switch.split('=', 2) (variables ||= {})[var] = val end end rescue # usage - STDERR.puts $!.to_s - STDERR.puts File.basename($0) + - " [switches] [var=value...] [inputfile]" + message = $!.to_s + STDERR.puts message unless message.empty? + STDERR.puts 'Usage:' + STDERR.puts " #{File.basename($0)} [options] [filepaths]" STDERR.puts <<EOU - -x print ruby script - -n print ruby script with line number - -v enable verbose mode - -d set $DEBUG to true - -r library load a library - -E ex[:in] set default external/internal encodings - -U set default encoding to UTF-8 - -T trim_mode specify trim_mode (0..2, -) - -P disable ruby code evaluation for lines beginning with % - var=value set variable + +Options: + -d --debug Set $DEBUG to enable debugging. + -E ex[:in] --encoding ex[:in] + Set default external and internal encodings. + -h --help Print this text and exit. + -n Print generated Ruby source code with line numbers; + ignored if given without option -x. + -P Disable execution tag shorthand (for lines beginning with '%'). + -r library Load the named library. + -T trim_mode Specify trim_mode: + '0' means '%'; '1' means '%>'; '2' means '<>'; '-' means '%-'. + -U Set default encoding to UTF-8. + -v Set $VERBOSE to enable debugging, + --version Print ERB version string and exit. + -x Print generated Ruby source code. + -- Treat all following words as filepaths (not options). + name=value Set the variable named name to the given string value. + +Filepaths: + The erb program reads the text from all files at the filepaths as a single ERB template: + plain text, possibly with embedded ERB tags; + filepaths may be repeated. + + The pseudo-filepath '-' (hyphen character) specifies the standard input. + + If no filepaths are given, the sole input is the standard input. + +See details and examples at https://docs.ruby-lang.org/en/master/erb_executable_md.html EOU exit 1 end @@ -127,12 +142,7 @@ EOU filename = $FILENAME exit 2 unless src trim = trim_mode_opt(trim_mode, disable_percent) - if safe_level.nil? - erb = factory.new(src, trim_mode: trim) - else - # [deprecated] This will be removed at Ruby 2.7. - erb = factory.new(src, safe_level, trim_mode: trim) - end + erb = factory.new(src, trim_mode: trim) erb.filename = filename if output if number |
