From 99966e5f36c77a9c2765697d2f6a58d5fb317f26 Mon Sep 17 00:00:00 2001 From: fjfarina Date: Sun, 31 Mar 2019 02:41:42 -0300 Subject: [PATCH] Linux player music stdout fix --- lib/nyan_cat_format/music.rb | 4 ++-- spec/nyan_cat_music_formatter_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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