Bug 162642

Summary: .sh scripts in /usr/local/etc/rc.d get executed, not sourced
Product: Base System Reporter: Andre.Albsmeier
Component: confAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Overcome By Events    
Severity: Affects Only Me    
Priority: Normal    
Version: 7.4-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Andre.Albsmeier 2011-11-17 14:50:15 UTC
man rc.subr says:

     run_rc_script file argument
           Start the script file with an argument of argument, and handle the
           return value from the script.

           Various shell variables are unset before file is started:

                 name, command, command_args, command_interpreter,
                 extra_commands, pidfile, rcvar, required_dirs,
                 required_files, required_vars, argument_cmd, argument_precmd.
                 argument_postcmd.

           The startup behaviour of file depends upon the following checks:

           1.   If file ends in .sh, it is sourced into the current shell.

           2.   If file appears to be a backup or scratch file (e.g., with a
                suffix of ~, #, .OLD, or .orig), ignore it.

           3.   If file is not executable, ignore it.

           4.   If the rc.conf(5) variable rc_fast_and_loose is empty, source
                file in a sub shell, otherwise source file into the current
                shell.

This is only true for .sh scripts sitting in /etc/rc.d
but not for other locations.

How-To-Repeat: 
put test.sh into /usr/local/etc/rc.d and it will get executed
in a subshell but not executed in the current shell.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-11-17 18:57:29 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-rc

Over to maintainer(s).
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:07 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped