From: rr.rosas@... Date: 2018-01-25T14:31:56+00:00 Subject: [ruby-core:85116] [Ruby trunk Feature#14386] Add option to let Kernel.#system raise error instead of returning false Issue #14386 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas). Thanks, Takashi, but very often in my code, when dealing with output and error management of external commands, I end up wrapping them in a utility method of my own to properly handle errors and control flow anyway, so I'm not sure I'm interested in creating an issue for that :) I just mentioned the return value here because it made sense to me when I read the proposal, not because I care too much about it ;) But thanks anyway for mentioning where I should suggest such method addition if I wanted to :) And thanks for the patch, as I think I'll have some use for it in some of my code. ---------------------------------------- Feature #14386: Add option to let Kernel.#system raise error instead of returning false https://bugs.ruby-lang.org/issues/14386#change-69832 * Author: k0kubun (Takashi Kokubun) * Status: Closed * 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: