You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I confirm this feature has not been previously requested
I have searched the issues and this feature has not previously been requested
Example of current nested code
function ignore_msrs_always() {
# Make sure the host has /etc/modprobe.d
if [ -d /etc/modprobe.d ]; then
# Skip if ignore_msrs is already enabled, assumes initramfs has been rebuilt
if grep -lq 'ignore_msrs=Y' /etc/modprobe.d/kvm-quickemu.conf >/dev/null 2>&1; then
echo "options kvm ignore_msrs=Y" | sudo tee /etc/modprobe.d/kvm-quickemu.conf
sudo update-initramfs -k all -u
fi
else
echo "ERROR! /etc/modprobe.d was not found, I don't know how to configure this system."
exit 1
fi
}
Describe the solution you'd like: Exit early, so no else clause needed, code gets simpler and more easy to read
function ignore_msrs_always() {
# Make sure the host has /etc/modprobe.d
if [ ! -d /etc/modprobe.d ]; then
echo "ERROR! /etc/modprobe.d was not found, I don't know how to configure this system."
exit 1
fi
# Skip if ignore_msrs is already enabled, assumes initramfs has been rebuilt
grep -lq 'ignore_msrs=Y' /etc/modprobe.d/kvm-quickemu.conf >/dev/null 2>&1 && return
# if all conditions met, write file
echo "options kvm ignore_msrs=Y" | sudo tee /etc/modprobe.d/kvm-quickemu.conf
sudo update-initramfs -k all -u
}
I confirm this feature has not been previously requested
Example of current nested code
Describe the solution you'd like: Exit early, so no else clause needed, code gets simpler and more easy to read
See e.g. Computer Programming/Coding Style/Minimize nesting “Flat is better than nested”
The text was updated successfully, but these errors were encountered: