R
RichardOnRails
gets looks to ARGV, if populated, for its source of data. That is its
documented behavior.
I want to:
1) use ARGV to point to a directory I want to process and
2) use gets to inquire whether the user wants the program to proceed
with that directory.
I thought I might be able to reset ARGV to an empty array after I
saved its content, but that doesn't work. Is there a way around this.
The following code never pauses to allow the user to enter yes/no, as
I intended it to. Is there a workaround?
=== Code ==
puts "ARGV = %s" % ARGV.join(", ")
argv = ARGV[0] # Save ARGV's content
ARGV = [] # Reset ARGV to an empty array
puts "Delete indicated item [yes, no]"
STDOUT.flush
response = gets.chomp # doesn't go to STDIN !!!
puts case response
when /^yes$/i; "Deleting"
when /^no$/i; "Quiting"
else; "Huh?"
end
puts "EOJ"
puts "EOJ"
documented behavior.
I want to:
1) use ARGV to point to a directory I want to process and
2) use gets to inquire whether the user wants the program to proceed
with that directory.
I thought I might be able to reset ARGV to an empty array after I
saved its content, but that doesn't work. Is there a way around this.
The following code never pauses to allow the user to enter yes/no, as
I intended it to. Is there a workaround?
=== Code ==
puts "ARGV = %s" % ARGV.join(", ")
argv = ARGV[0] # Save ARGV's content
ARGV = [] # Reset ARGV to an empty array
puts "Delete indicated item [yes, no]"
STDOUT.flush
response = gets.chomp # doesn't go to STDIN !!!
puts case response
when /^yes$/i; "Deleting"
when /^no$/i; "Quiting"
else; "Huh?"
end
puts "EOJ"
puts "EOJ"