Skip to content

Commit a5c4141

Browse files
committed
Fix handling of double dashes -- in crystal eval command
1 parent 1cf95a8 commit a5c4141

File tree

1 file changed

+9
-11
lines changed
  • src/compiler/crystal/command

1 file changed

+9
-11
lines changed

src/compiler/crystal/command/eval.cr

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@
33
class Crystal::Command
44
private def eval
55
compiler = new_compiler
6+
program_source = ""
7+
program_args = [] of String
8+
69
parse_with_crystal_opts do |opts|
710
opts.banner = "Usage: crystal eval [options] [source]\n\nOptions:"
811
setup_simple_compiler_options compiler, opts
12+
13+
opts.unknown_args do |before_dash, after_dash|
14+
program_source = before_dash.join " "
15+
program_args = after_dash
16+
end
917
end
1018

11-
if options.empty?
19+
if program_source.empty?
1220
program_source = STDIN.gets_to_end
13-
program_args = [] of String
14-
else
15-
double_dash_index = options.index("--")
16-
if double_dash_index
17-
program_source = options[0...double_dash_index].join " "
18-
program_args = options[double_dash_index + 1..-1]
19-
else
20-
program_source = options.join " "
21-
program_args = [] of String
22-
end
2321
end
2422

2523
sources = [Compiler::Source.new("eval", program_source)]

0 commit comments

Comments
 (0)