Changeset View
Changeset View
Standalone View
Standalone View
libexec/rc/rc.subr
Show First 20 Lines • Show All 1,030 Lines • ▼ Show 20 Lines | fi | ||||
# if there's a custom ${XXX_cmd}, | # if there's a custom ${XXX_cmd}, | ||||
# run that instead of the default | # run that instead of the default | ||||
# | # | ||||
eval _cmd=\$${rc_arg}_cmd \ | eval _cmd=\$${rc_arg}_cmd \ | ||||
_precmd=\$${rc_arg}_precmd \ | _precmd=\$${rc_arg}_precmd \ | ||||
_postcmd=\$${rc_arg}_postcmd | _postcmd=\$${rc_arg}_postcmd | ||||
if [ -n "$_cmd" ]; then | if [ -n "$_cmd" ]; then | ||||
set -a | |||||
eval $_env | |||||
set +a | |||||
jilles: This should have an effect as close as possible to the effect without a _cmd. In that case… | |||||
_run_rc_precmd || return 1 | _run_rc_precmd || return 1 | ||||
_run_rc_doit "$_cmd $rc_extra_args" || return 1 | _run_rc_doit "$_cmd $rc_extra_args" || return 1 | ||||
_run_rc_postcmd | _run_rc_postcmd | ||||
return $_return | return $_return | ||||
fi | fi | ||||
case "$rc_arg" in # default operations... | case "$rc_arg" in # default operations... | ||||
▲ Show 20 Lines • Show All 1,143 Lines • Show Last 20 Lines |
This should have an effect as close as possible to the effect without a _cmd. In that case, env plus the value of _env is prepended to the command and this is passed to eval. The code above first applies word splitting and pathname generation to the value of _env, concatenates it with spaces and evals it as shell variable assignments.
So I suggest instead:
This applies exactly one expansion pass, a full shell parse and expansion.
The -- will cause any attempt to use options to fail. There are no options that agree between export and env.
Differently from env, export will not set environment variables that do not have a proper name (consisting solely of alphabetics, numerics, and underscores, and starting with an alphabetic or an underscore). There is no way the shell allows this, so this difference cannot be fixed.