Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Jan 2012 09:45:58 -0500
From:      Matthew Story <matthewstory@gmail.com>
To:        =?KOI8-R?B?68/O2MvP1yDl18fFzsnK?= <kes-kes@yandex.ru>
Cc:        freebsd-bugs@freebsd.org
Subject:   Re: Re[2]: misc/164011: comments in rc.conf cause system loading
Message-ID:  <CAB%2B9ogde8VZcRXBaV4_4vp9Zu4T6HHfx4Jr3b=j7DEU-AUDVOw@mail.gmail.com>
In-Reply-To: <217378425.20120111120149@yandex.ru>
References:  <201201110800.q0B80Ug4093353@freefall.freebsd.org> <217378425.20120111120149@yandex.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
2012/1/11 =EB=CF=CE=D8=CB=CF=D7 =E5=D7=C7=C5=CE=C9=CA <kes-kes@yandex.ru>

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

=FA=C4=D2=C1=D7=D3=D4=D7=D5=CA=D4=C5, Matthew.
> [... snip]
> =F7=D9 =D0=C9=D3=C1=CC=C9 11 =D1=CE=D7=C1=D2=D1 2012 =C7., 10:00:30:
> #this test FAIL
> echo "Test 7"
> dddd=3D""
> dddd=3D"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=3Dbar python -c "import os; print os.environ[\"foo\"];"'
bar

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


> [...snip]
> #Despite on "Test 2" SUCCESS this "Test 9" FAIL
> echo "Test 9"
> dddd=3D""
> dddd=3D"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=3D"bar"#!; echo "$foo"'
bar#!

[...snip]
>

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
following
     actions:

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

for POSIX specification on this topic, see:

http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta=
g_02_09_01
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta=
g_02_10_02

--=20
regards,
matt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAB%2B9ogde8VZcRXBaV4_4vp9Zu4T6HHfx4Jr3b=j7DEU-AUDVOw>