diff options
author | Miloslav Trmac <mitr@volny.cz> | 2006-07-27 02:17:03 +0000 |
---|---|---|
committer | Miloslav Trmac <mitr@volny.cz> | 2006-07-27 02:17:03 +0000 |
commit | 3db5ad738151d27001658d570bce0c61648fc2cc (patch) | |
tree | fcb9a69ac7f3896e0636f929fd87f13828c51852 /rc.d | |
parent | 02315ee166c1625d9524a783a1ad49383a4623db (diff) | |
download | initscripts-3db5ad738151d27001658d570bce0c61648fc2cc.tar initscripts-3db5ad738151d27001658d570bce0c61648fc2cc.tar.gz initscripts-3db5ad738151d27001658d570bce0c61648fc2cc.tar.bz2 initscripts-3db5ad738151d27001658d570bce0c61648fc2cc.tar.xz initscripts-3db5ad738151d27001658d570bce0c61648fc2cc.zip |
Consistently exclude backup files when globbing
Diffstat (limited to 'rc.d')
-rwxr-xr-x | rc.d/init.d/functions | 12 | ||||
-rwxr-xr-x | rc.d/init.d/network | 9 | ||||
-rwxr-xr-x | rc.d/rc | 8 | ||||
-rwxr-xr-x | rc.d/rc.sysinit | 1 |
4 files changed, 18 insertions, 12 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 19a86c16..2576f463 100755 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -573,3 +573,15 @@ resolve_dm_name() { /sbin/dmsetup table | egrep -iv "no block devices found|No devices found" | sed -n "s/\(^[^:]\+\): $newline\( \+$\|$\)/\1/p" ) 2>/dev/null } + +# Check whether file $1 is a backup or rpm-generated file and should be ignored +is_ignored_file() { + case "$1" in + *~ | *.bak | *.orig | *.rpmnew | *.rpmorig | *.rpmsave) + return 0 + ;; + esac + return 1 +} +# A sed expression to filter out the files that is_ignored_file recognizes +__sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d' diff --git a/rc.d/init.d/network b/rc.d/init.d/network index a16a2692..19fa0264 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -43,13 +43,12 @@ cd /etc/sysconfig/network-scripts # find all the interfaces besides loopback. # ignore aliases, alternative configurations, and editor backup files -interfaces=`ls ifcfg* | \ - LANG=C sed -e '/\(ifcfg-lo\|:\|ifcfg-.*-range\)/d' \ - -e '/\(rpmsave\|rpmorig\|rpmnew\)/d' \ - -e '/\(~\|\.bak\)$/d' \ +interfaces=$(ls ifcfg* | \ + LANG=C sed -e "$__sed_discard_ignored_files" \ + -e '/\(ifcfg-lo\|:\|ifcfg-.*-range\)/d' \ -e '/ifcfg-[A-Za-z0-9\._-]\+$/ { s/^ifcfg-//g;s/[0-9]/ &/}' | \ LANG=C sort -k 1,1 -k 2n | \ - LANG=C sed 's/ //'` + LANG=C sed 's/ //') # See how we were called. case "$1" in @@ -12,13 +12,7 @@ check_runlevel () { # Check if the file exists at all. [ -x "$1" ] || return 1 - - # Reject backup files and files generated by rpm. - case "$1" in - *.rpmsave|*.rpmorig|*.rpmnew|*~|*.orig) - return 1 - ;; - esac + is_ignored_file "$1" && return 1 return 0 } diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit index e48d700b..f2139626 100755 --- a/rc.d/rc.sysinit +++ b/rc.d/rc.sysinit @@ -496,6 +496,7 @@ if [ "$READONLY" = "yes" ]; then fi for file in /etc/rwtab /etc/rwtab.d/* ; do + is_ignored_file "$file" && continue [ -f $file ] && cat $file | while read type path ; do case "$type" in empty) |