I'd like to write the following test in an installer script1:
if [ -n "`/etc/grub.d/30_os-prober`" ]; then
install_dual_boot
else
install_linux_only
fi
However, it's also possible that 30_os-prober
produces no output because it somehow failed to complete. If 30_os-prober
fails with a non-zero exit status, it would be safer to assume the a dual-boot situation.
How can I check that 30_os-prober
produced no output successfully?
Basically, I would like to obtain an effect similar to…
if [ -n "`/etc/grub.d/30_os-prober`" ]; then
# Do stuff for a dual-boot machine
install_dual_boot
elif ! /etc/grub.d/30_os-prober >/dev/null; then
# OS probe failed; assume dual boot out of abundance of caution
install_dual_boot
else
install_linux_only
fi
… but without running the same command twice.
1 Background information: 30_os-prober
comes with GRUB2, and the script I am writing is part of my custom configuration for FAI.
[]
's of anif
statement... – Andrew Henle Jun 08 '15 at 21:24[]
's. As ferada's answer shows.... – Andrew Henle Jun 08 '15 at 21:45if [ -z … ] then install_dual_boot
but the second one saysif [ -n … ] then install_dual_boot
. – Scott - Слава Україні Jun 09 '15 at 07:00