diff --git a/lib/nyan_cat_format/music.rb b/lib/nyan_cat_format/music.rb index 41e8702..dab4dd3 100644 --- a/lib/nyan_cat_format/music.rb +++ b/lib/nyan_cat_format/music.rb @@ -51,7 +51,7 @@ def kill_music def linux_player %w{mpg321 mpg123}.find {|player| - kernel.system("which #{ player } &>/dev/null && type #{ player } &>/dev/null") + kernel.system("which #{player} > /dev/null 2>&1 && type #{player} > /dev/null 2>&1") } end @@ -61,7 +61,7 @@ def music_command if osx? @music_command = "afplay #{nyan_mp3}" elsif linux? && linux_player - @music_command = "#{ linux_player } #{ nyan_mp3 } &>/dev/null" + @music_command = "#{linux_player} #{nyan_mp3} > /dev/null 2>&1" end end diff --git a/spec/nyan_cat_music_formatter_spec.rb b/spec/nyan_cat_music_formatter_spec.rb index c7ac675..fbff223 100644 --- a/spec/nyan_cat_music_formatter_spec.rb +++ b/spec/nyan_cat_music_formatter_spec.rb @@ -82,14 +82,14 @@ def seen allow(mock_kernel).to receive(:system).with(match(/which mpg123/)).and_return(true) allow(mock_kernel).to receive(:system).with(match(/which mpg321/)).and_return(false) formatter.start 10 - expect(mock_kernel.seen.any? { |entry| entry. end_with? "mpg123 #{path_to_mp3} &>/dev/null" }).to be + expect(mock_kernel.seen.any? { |entry| entry. end_with? "mpg123 #{path_to_mp3} > /dev/null 2>&1" }).to be end it 'plays the song for linux too with mpg321 when available' do allow(mock_kernel).to receive(:system).with(match(/which mpg321/)).and_return(true) allow(mock_kernel).to receive(:system).with(match(/which mpg123/)).and_return(false) formatter.start 10 - expect(mock_kernel.seen.any? { |entry| entry. end_with? "mpg321 #{path_to_mp3} &>/dev/null" }).to be + expect(mock_kernel.seen.any? { |entry| entry. end_with? "mpg321 #{path_to_mp3} > /dev/null 2>&1" }).to be end end