summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-29 09:26:42 (GMT)
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-29 09:26:42 (GMT)
commitbbd1a18aafe5b8ba3c1a698526fcc62a7f0af1d1 (patch)
tree204deafe3c77a4c485f892c9fda28ed014a7ceb1 /bin
parentaf91b4235416af1ec499afafcf4524d93437607b (diff)
* bin/erb: accepts options in more flexible styles.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bin')
-rwxr-xr-xbin/erb24
1 files changed, 17 insertions, 7 deletions
diff --git a/bin/erb b/bin/erb
index d265641..6db3d0b 100755
--- a/bin/erb
+++ b/bin/erb
@@ -12,9 +12,17 @@ class ERB
arg = self.shift
return nil if arg == '--'
if arg =~ /^-(.)(.*)/
- return arg if $1 == '-'
- raise 'unknown switch "-"' if $2.index('-')
- self.unshift "-#{$2}" if $2.size > 0
+ if $1 == '-'
+ arg, @maybe_arg = arg.split(/=/, 2)
+ return arg
+ end
+ raise 'unknown switch "-"' if $2[0] == ?- and $1 != 'T'
+ if $2.size > 0
+ self.unshift "-#{$2}"
+ @maybe_arg = $2
+ else
+ @maybe_arg = nil
+ end
"-#{$1}"
else
self.unshift arg
@@ -23,7 +31,9 @@ class ERB
end
def ARGV.req_arg
- self.shift || raise('missing argument')
+ (@maybe_arg || self.shift || raise('missing argument')).tap {
+ @maybe_arg = nil
+ }
end
def trim_mode_opt(trim_mode, disable_percent)
@@ -94,11 +104,11 @@ class ERB
-n print ruby script with line number
-v enable verbose mode
-d set $DEBUG to true
- -r [library] load a library
- -S [safe_level] set $SAFE (0..4)
+ -r library load a library
+ -S safe_level set $SAFE (0..4)
-E ex[:in] set default external/internal encodings
-U set default encoding to UTF-8.
- -T [trim_mode] specify trim_mode (0..2, -)
+ -T trim_mode specify trim_mode (0..2, -)
-P ignore lines which start with "%"
EOU
exit 1