U
Une bévue
something i don't understand : gets give me last arg of script ???
here is part of my script :
------------------------------------------------------------------------
def get_respons
return (/^[y|Y|O|o].*/ === gets.to_s.chomp)
end
dir_path=Dir.pwd
dir_path=$*[0] if $*.length == 1
puts "Are you sure you want to convert #{dir_path} ?[y|Y|O|o/n] default
to NO"
if get_respons
puts "reponse YES"
end
------------------------------------------------------------------------
and the script (being in my $PATH) is called from terminal :
and the message error i get is :
nil
/Users/yvon/bin/set_date:7:in `gets': Is a directory - /Users/yvon
(Errno::EISDIR)
from /Users/yvon/bin/set_date:7:in `get_reponse'
from /Users/yvon/bin/set_date:17
line 7 being "return (/^[y|Y|O|o].*/ === gets.to_s.chomp)"
and 17 the call to "get_respons" : "if get_respons"
notice the $*[0] is allready used in my script ???
here is part of my script :
------------------------------------------------------------------------
def get_respons
return (/^[y|Y|O|o].*/ === gets.to_s.chomp)
end
dir_path=Dir.pwd
dir_path=$*[0] if $*.length == 1
puts "Are you sure you want to convert #{dir_path} ?[y|Y|O|o/n] default
to NO"
if get_respons
puts "reponse YES"
end
------------------------------------------------------------------------
and the script (being in my $PATH) is called from terminal :
set_date /Users/yvon
and the message error i get is :
Are you sure you want to convert /Users/yvon ?[y|Y|O|o/n] default to NOset_date /Users/yvon
nil
/Users/yvon/bin/set_date:7:in `gets': Is a directory - /Users/yvon
(Errno::EISDIR)
from /Users/yvon/bin/set_date:7:in `get_reponse'
from /Users/yvon/bin/set_date:17
line 7 being "return (/^[y|Y|O|o].*/ === gets.to_s.chomp)"
and 17 the call to "get_respons" : "if get_respons"
notice the $*[0] is allready used in my script ???