From: shevegen@... Date: 2018-01-23T17:52:09+00:00 Subject: [ruby-core:85015] [Ruby trunk Feature#14386] Add option to let Kernel.#system raise error instead of returning false Issue #14386 has been updated by shevegen (Robert A. Heiler). If I understood it correctly, you mean to pass in an optional hash to be the second argument to system() right? I have nothing against it. I think it would change existing behaviour though, if I read http://ruby-doc.org/core-2.5.0/Kernel.html#method-i-system correctly, so perhaps this may have to be targeted for 3.0, if matz approves of it? Though it may be that I misunderstood the suggestion. To the name, I think assert_status is ok, even if it is a bit verbose. I can't think of a shorter one though... the one word variants I can think of are less meaningful than assert_status. I could think of assert_runtime or assert_raise or something like that but all of these variants are not great really ... so assert_status seems somewhat ok to me. ---------------------------------------- Feature #14386: Add option to let Kernel.#system raise error instead of returning false https://bugs.ruby-lang.org/issues/14386#change-69722 * Author: k0kubun (Takashi Kokubun) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- I sometimes write code like: ~~~ ruby system('git pull origin master') || raise('Failed to execute: git pull origin master') system('bundle check || bundle install') || raise('Failed to execute: bundle check || bundle install') ~~~ Using rake, we can simplify the above code to the following one, but there's no way to do that outside Rakefile. (Note that I just want to do the same thing as "bash -e", the error message is actually not important.) ~~~ ruby sh 'git pull origin master' sh 'bundle check || bundle install' ~~~ If we add the following option, we can simplify such code even when we're not on a rake task. I'm not sure whether it's a good name or not though. ~~~ ruby system 'git pull origin master', assert_status: true system 'bundle check || bundle install', assert_status: true # => RuntimeError: Command failed with status (1): bundle check || bundle install ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: