Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3882)

Issue 116042: rc: fix import of function definitions from environment

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 7 months ago by knieriem
Modified:
8 years, 7 months ago
Reviewers:
russcox
CC:
old.codebot
Visibility:
Public.

Description

In rc subshells, there might be two definitions of a function fn#... of the same name in the environment. To reproduce, type fn a{echo a} rc -c 'env | grep fn' It will show fn#a twice. In plan9ish.c's Vinit() rc will go through the environment and add internal variables for each environment variable found. It will also create variables named fn#..., i.e. normal variables, not functions. At another place, Xrdfn(), the fn#-style function definitions are actually interpreted. So in case an rc function already had been defined when rc was started, mkenv() later will create two environment entries "fn#a", one for the internal variable created previously within Vinit(), and a second one for the function definition, created in Xrdfn(). The patch prevents function definitions from being added as internal variables in Vinit, similar as it is done in Plan 9's rc. [ Some lines down there is a sequnce case '(': /* ignore functions for now */ break; It seems that in the past it might have had a similar purpose, but probably related to the Bourne shell ... There is a corresponding place within an "#if 0" block in Xrdfn. ]

Patch Set 1 #

Patch Set 2 : The patch now contains the inverted test. #

Patch Set 3 : The patch now contains the inverted test. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2 lines, -0 lines) Patch
M src/cmd/rc/plan9ish.c View 1 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 4
knieriem
14 years, 7 months ago (2009-09-03 22:11:10 UTC) #1
rsc_swtch
Could you leave the existing code where it is and before it put if(strcmp(..., "fn#", ...
14 years, 7 months ago (2009-09-03 22:25:53 UTC) #2
knieriem
14 years, 7 months ago (2009-09-03 22:40:50 UTC) #3
knieriem
14 years, 7 months ago (2009-09-03 22:42:19 UTC) #4

          
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b