misc/164011: comments in rc.conf cause system loading

Matthew Story matthewstory at gmail.com
Wed Jan 11 15:13:57 UTC 2012

2012/1/11 Коньков Евгений <kes-kes at yandex.ru>

we're pretty far away from rc.conf bugs here, but all of these tests
demonstrate proper functionality of a POSIX shell.

Здравствуйте, Matthew.
> [... snip]
> Вы писали 11 января 2012 г., 10:00:30:
> #this test FAIL
> echo "Test 7"
> dddd=""
> dddd="ddd"# ddd
> echo $dddd

per the shell man page, assignment prior to a simple command exposes the
assigned variable to the simple command's environment.  what your example
above is actually doing, is the following:

assign 'ddd#' to the environment variable 'dddd'
exec ddd (does not exist)

when you get to the echo, dddd is equal to the value "", not the value
exposed to ddd's environment.  for a useful use of this feature:

$ sh -c 'foo=bar python -c "import os; print os.environ[\"foo\"];"'

relevant snippet from the man page and POSIX spec at the bottom of this

> [...snip]
> #Despite on "Test 2" SUCCESS this "Test 9" FAIL
> echo "Test 9"
> dddd=""
> dddd="ddd"#! ddd
> echo $dddd

this does exactly the same as case 7, excepting the value 'ddd#!' is
assigned to dddd in ddd's environment prior to executing ddd.

sh -c 'foo="bar"#!; echo "$foo"'


the rest of the examples are variations on the same theme.

------from man 1 sh-------

   Simple Commands
     If a simple command has been recognized, the shell performs the

     1.   Leading words of the form ``name=value'' are stripped off and
          assigned to the environment of the simple command.  Redirection
          operators and their arguments (as described below) are stripped
          and saved for processing.

for POSIX specification on this topic, see:



More information about the freebsd-bugs mailing list