Bug 162642 - .sh scripts in /usr/local/etc/rc.d get executed, not sourced
Summary: .sh scripts in /usr/local/etc/rc.d get executed, not sourced
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 7.4-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-17 14:50 UTC by Andre.Albsmeier
Modified: 2017-12-31 22:32 UTC (History)
0 users

See Also:


Attachments
file.diff (354 bytes, patch)
2011-11-17 14:50 UTC, Andre.Albsmeier
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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