Forum: Ruby Is there something built-in for this ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
91eb330fb36d1e03c856574dfb77d2bc?d=identicon&s=25 Thibaut Barrère (thbar)
on 2009-02-05 14:55
(Received via mailing list)
Hi,

very often I use this method:

def launch(cmd)
  raise "Error launching #{cmd}" unless system(cmd)
end

Is there a built-in equivalent ?

cheers,

-- Thibaut
91eb330fb36d1e03c856574dfb77d2bc?d=identicon&s=25 Thibaut Barrère (thbar)
on 2009-02-08 10:10
(Received via mailing list)
> begin
>   system(cmd)
> rescue NameError => e
>   puts e
> end
>
> ... Does that help you ?

hum -- not sure actually. Is system() supposed to raise a NameError ?
I didn't see this mentioned in the docs.

I searched further yet could not find anything like launch() so far.

-- Thibaut
54404bcac0f45bf1c8e8b827cd9bb709?d=identicon&s=25 7stud -- (7stud)
on 2009-02-08 13:14
Thibaut Barrère wrote:
>> begin
>> � system(cmd)
>> rescue NameError => e
>> � puts e
>> end
>>
>> ... Does that help you ?
>
> hum -- not sure actually. Is system() supposed to raise a NameError ?
> I didn't see this mentioned in the docs.
>

Easy enough to test:

begin
  result = system("made up command")
  puts result
rescue NameError => e
  puts e
end

--output:--
false
This topic is locked and can not be replied to.