From a87068f040d3af38ac08e56df6d8c2aaab56c4e5 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Thu, 7 Jul 2011 23:09:46 +0000 Subject: [PATCH] Eliminate some $? tests by rolling the command into the condition ok halex@ --- src/etc/netstart | 8 +++----- src/etc/rc | 5 ++--- src/etc/weekly | 5 ++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/etc/netstart b/src/etc/netstart index 887844c1..fa9ab632 100644 --- a/src/etc/netstart +++ b/src/etc/netstart @@ -1,6 +1,6 @@ #!/bin/sh - # -# $OpenBSD: netstart,v 1.132 2011/05/26 15:22:53 mpf Exp $ +# $OpenBSD: netstart,v 1.133 2011/07/07 23:09:46 guenther Exp $ # Strip comments (and leading/trailing whitespace if IFS is set) # from a file and spew to stdout @@ -47,11 +47,9 @@ ifstart() { chmod -LR o-rwx $file chown -LR root.wheel $file fi - ifconfig $if > /dev/null 2>&1 - if [ "$?" != "0" ]; then + if ! ifconfig $if > /dev/null 2>&1; then # Try to create interface if it does not exist - ifconfig $if create > /dev/null 2>&1 - if [ "$?" != "0" ]; then + if ! ifconfig $if create > /dev/null 2>&1; then return fi fi diff --git a/src/etc/rc b/src/etc/rc index e2df54f3..2d229112 100644 --- a/src/etc/rc +++ b/src/etc/rc @@ -1,4 +1,4 @@ -# $OpenBSD: rc,v 1.363 2011/07/07 22:57:29 deraadt Exp $ +# $OpenBSD: rc,v 1.364 2011/07/07 23:09:46 guenther Exp $ # System startup script run by init on autoboot # or after single-user. @@ -518,8 +518,7 @@ fi if [ ! -f /etc/motd ]; then install -c -o root -g wheel -m 664 /dev/null /etc/motd fi -T=`mktemp /tmp/_motd.XXXXXXXXXX` -if [ $? -eq 0 ]; then +if T=`mktemp /tmp/_motd.XXXXXXXXXX`; then sysctl -n kern.version | sed 1q > $T echo "" >> $T sed '1,/^$/d' < /etc/motd >> $T diff --git a/src/etc/weekly b/src/etc/weekly index ff00fffa..9e5585aa 100644 --- a/src/etc/weekly +++ b/src/etc/weekly @@ -1,5 +1,5 @@ # -# $OpenBSD: weekly,v 1.24 2011/01/19 06:18:05 david Exp $ +# $OpenBSD: weekly,v 1.25 2011/07/07 23:09:46 guenther Exp $ # # For local additions, create the file /etc/weekly.local. # To get section headers, use the function next_part in weekly.local. @@ -45,8 +45,7 @@ run_script "weekly.local" next_part "Rebuilding locate database:" if [ -f /var/db/locate.database ]; then - TMP=`mktemp /var/db/locate.database.XXXXXXXXXX` - if [ $? -eq 0 ]; then + if TMP=`mktemp /var/db/locate.database.XXXXXXXXXX`; then trap 'rm -f $TMP; exit 1' 0 1 15 UPDATEDB="/usr/libexec/locate.updatedb" echo "${UPDATEDB} --fcodes=- --tmpdir=${TMPDIR:-/var/tmp}" | \