From: Ryan Davis Date: 2010-02-01T15:18:32+09:00 Subject: Re: Workaround for "conflict" between ARGV and gets? On Jan 31, 2010, at 20:15 , RichardOnRails wrote: > 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 !!! ri IO.gets ri Kernel.gets