Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc Improve run_rc_script():



details:   https://anonhg.NetBSD.org/src/rev/ebb0118593cc
branches:  trunk
changeset: 511336:ebb0118593cc
user:      lukem <lukem%NetBSD.org@localhost>
date:      Mon Jun 18 06:53:45 2001 +0000

description:
Improve run_rc_script():
- Skip files that end with `~', `#', `.OLD' or `.orig', as these are usually
  scratch or backup files created by programs, and we don't want to start them.
- Only try and run non `.sh' files if they're executable.

Per discussions with Andrew Brown, and closing his PR [bin/9981].

diffstat:

 etc/rc.subr |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r 7ec48923b615 -r ebb0118593cc etc/rc.subr
--- a/etc/rc.subr       Mon Jun 18 06:42:35 2001 +0000
+++ b/etc/rc.subr       Mon Jun 18 06:53:45 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: rc.subr,v 1.36 2001/05/10 14:04:22 atatat Exp $
+# $NetBSD: rc.subr,v 1.37 2001/06/18 06:53:45 lukem Exp $
 #
 # Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -547,11 +547,12 @@
 # run_rc_script file arg
 #      Start the script `file' with `arg', and correctly handle the
 #      return value from the script.  If `file' ends with `.sh', it's
-#      sourced into the current environment.  Otherwise it's run as
-#      a child process.
+#      sourced into the current environment.  If `file' appears to be
+#      a backup or scratch file, ignore it.  Otherwise if it's
+#      executable run as a child process.
 #
 #      Note: because `.sh' files are sourced into the current environment
-#      run_rc_command shouldn't be used because its difficult to ensure
+#      run_rc_command() shouldn't be used because its difficult to ensure
 #      that the global variable state before and after the sourcing of 
 #      the .sh file won't adversely affect other scripts.
 #
@@ -573,8 +574,13 @@
                *.sh)                           # run in current shell
                        set $_arg ; . $_file
                        ;;
+               *[~#]|*.OLD|*.orig)             # scratch file; skip
+                       warn "Ignoring scratch file $_file"
+                       ;;
                *)                              # run in subshell
-                       ( set $_arg ; . $_file )
+                       if [ -x $_file ]; then
+                               ( set $_arg ; . $_file )
+                       fi
                        ;;
                esac
        fi



Home | Main Index | Thread Index | Old Index