microsoft / mdatp-xplat

Microsoft Defender for macOS/Linux - config samples, auxiliary tools
MIT License
187 stars 188 forks source link

Add quiet option to yum repolist command #99

Closed ayush-m closed 1 year ago

ayush-m commented 1 year ago

Issue with current script:

Currently, script checks for existing configured repos in yum via yum repolist. Currently, repolist check always gives repository as configured even when not configured. This is because of following reason: yum repolist command by default also notifies about the current state or actions of DNF in output. So, that output will be captured in grep. e.g. I issued following command in rhel 8.7, and got this result.

sudo yum repolist nonexistingrepo | grep nonexistingrepo; echo "result=$?" Command: yum repolist nonexistingrepo Extra commands: ['repolist', 'nonexistingrepo'] Last metadata expiration check: 0:02:35 ago on Mon 24 Jul 2023 05:55:51 AM UTC. result=0

How this change addresses the problem mentioned above:

Added -q option in yum repolist command so that it shows just the relevant content and suppresses messages notifying about the current state or actions of DNF.