Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shellout! only fails if the last command in a block fails #894

Open
btm opened this issue Jul 24, 2019 · 0 comments
Open

shellout! only fails if the last command in a block fails #894

btm opened this issue Jul 24, 2019 · 0 comments

Comments

@btm
Copy link
Contributor

btm commented Jul 24, 2019

Description

When hdiutil fails in a shellout! block we continue anyway (producing an empty build) as long as the last command in the block succeeds.

Omnibus Version

6.0.30

Platform Version

Mac os Mojave 10.14.5

Replication Case

https://buildkite.com/chef/inspec-inspec-master-omnibus-release/builds/59#962a5eb3-a0f4-416c-9c10-362ffa9d9231/6-8385

These lines are failing. We probably need to put && on each command, but this pattern is used throughout the project.

hdiutil convert \\

In this example shellout! is happy because the last command returned 0

2.5.3 :028 >         shellout! <<-EOH.gsub(/^ {10}/, "")
2.5.3 :029"> false
2.5.3 :030"> true
2.5.3 :031"> EOH
 => <Mixlib::ShellOut#70164612236040: command: 'false
true
' process_status: #<Process::Status: pid 13924 exit 0> stdout: '' stderr: '' child_pid: 13924 environment: {} timeout: 7200 user:  group:  working_dir:  > 

but in this example shellout raises because the last command failed:

2.5.3 :024 >         shellout! <<-EOH.gsub(/^ {10}/, "")
2.5.3 :025"> true
2.5.3 :026"> false
2.5.3 :027"> EOH
Traceback (most recent call last):
        4: from /Users/btm/.rvm/rubies/ruby-2.5.3/bin/irb:11:in `<main>'
        3: from (irb):24
        2: from /Users/btm/.rvm/gems/ruby-2.5.3/gems/omnibus-6.0.30/lib/omnibus/util.rb:134:in `shellout!'
        1: from /Users/btm/.rvm/gems/ruby-2.5.3/gems/omnibus-6.0.30/lib/omnibus/util.rb:139:in `rescue in shellout!'
Omnibus::CommandFailed (The following shell command exited with status 1:)

    $ true
false


Output:

    (nothing)

Error:

    (nothing)

This provides the expected behavior:

2.5.3 :032 > shellout! <<-EOH.gsub(/^ {10}/, "")
2.5.3 :033"> false && \\
2.5.3 :034"> true
2.5.3 :035"> EOH
Traceback (most recent call last):
        4: from /Users/btm/.rvm/rubies/ruby-2.5.3/bin/irb:11:in `<main>'
        3: from (irb):32
        2: from /Users/btm/.rvm/gems/ruby-2.5.3/gems/omnibus-6.0.30/lib/omnibus/util.rb:134:in `shellout!'
        1: from /Users/btm/.rvm/gems/ruby-2.5.3/gems/omnibus-6.0.30/lib/omnibus/util.rb:139:in `rescue in shellout!'
Omnibus::CommandFailed (The following shell command exited with status 1:)

    $ false && \
true


Output:

    (nothing)

Error:

    (nothing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant