[arch-projects] [initscripts] [PATCH 14/18] Consequently Use '>|' when redirecting to files

Kurt J. Bosch kjb-temp-2009 at alpenjodel.de
Mon Jun 27 13:11:20 EDT 2011


This avoids errors if one should set the noclobber shell option somewhere (whithin a daemon script or some custom function).
We already had this, but it seems gone lost mostly.
---
 functions  |    4 ++--
 rc.sysinit |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/functions b/functions
index d24df8c..b3d2be4 100644
--- a/functions
+++ b/functions
@@ -176,7 +176,7 @@ in_array() {
 
 add_daemon() {
 	[[ -d /run/daemons ]] || /bin/mkdir -p /run/daemons
-	> /run/daemons/"$1"
+	>| /run/daemons/"$1"
 }
 
 rm_daemon() {
@@ -369,7 +369,7 @@ fsck_all() {
 		FORCEFSCK=
 		[[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-- -f"
 		run_hook sysinit_prefsck
-		fsck -A -T -C$FSCK_FD -a -t "$NETFS,noopts=_netdev" $FORCEFSCK >$FSCK_OUT 2>$FSCK_ERR
+		fsck -A -T -C$FSCK_FD -a -t "$NETFS,noopts=_netdev" $FORCEFSCK >|$FSCK_OUT 2>|$FSCK_ERR
 		local fsckret=$?
 		run_hook sysinit_postfsck
 	(( fsckret <= 1 )) && stat_done || stat_fail
diff --git a/rc.sysinit b/rc.sysinit
index ee16c23..adf276f 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -228,7 +228,7 @@ stat_done
 
 [[ $HOSTNAME ]] &&
 	status "Setting Hostname: $HOSTNAME" \
-		eval 'echo "$HOSTNAME" > /proc/sys/kernel/hostname'
+		eval 'echo "$HOSTNAME" >| /proc/sys/kernel/hostname'
 
 # Flush old locale settings and set user defined locale
 status "Setting Locale: ${LOCALE:=en_US}" \
@@ -243,7 +243,7 @@ if [[ ${LOCALE,,} =~ utf ]]; then
 			kbd_mode -u < ${i}
 			printf "\e%%G" > ${i}
 		done
-		echo 1 > /sys/module/vt/parameters/default_utf8
+		echo 1 >| /sys/module/vt/parameters/default_utf8
 	stat_done
 else
 	stat_busy "Setting Consoles to legacy mode"
@@ -252,7 +252,7 @@ else
 			kbd_mode -a < ${i}
 			printf "\e%%@" > ${i}
 		done
-		echo 0 > /sys/module/vt/parameters/default_utf8
+		echo 0 >| /sys/module/vt/parameters/default_utf8
 	stat_done
 fi
 [[ $KEYMAP ]] &&
-- 
1.7.1



More information about the arch-projects mailing list