<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>10196</bug_id>
          
          <creation_ts>2016-08-31 06:13:26 +0000</creation_ts>
          <short_desc>Suggested (currently missing) documentation for the &apos;export&apos; keyword</short_desc>
          <delta_ts>2016-09-01 23:39:09 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>9</classification_id>
          <classification>Documentation</classification>
          <product>BitBake User Manual</product>
          <component>bitbake-manual</component>
          <version>2.2</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>01 Sept 2016: RESOLVED</status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.2 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>ulfalizer</reporter>
          <assigned_to name="Scott Rifenbark">srifenbark</assigned_to>
          <cc>bluelightning</cc>
    
    <cc>srifenbark</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Done (doc changes complete)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>65627</commentid>
    <comment_count>0</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-08-31 06:13:26 +0000</bug_when>
    <thetext>Hello,

The &apos;export&apos; keyword appears in a few places but is never explicitly documented and easy to miss. I suggest adding the following documentation:

  3.2. Exporting Variables to the Environment
  
    Variables can be exported to the environment of running tasks by using the
    &apos;export&apos; keyword. For example, in the following snippet, the do_foo task prints
    &quot;value from the environment&quot; when run.
    
      export ENV_VARIABLE
      ENV_VARIABLE = &quot;value from the environment&quot;
    
      do_foo() {
          bbplain &quot;$ENV_VARIABLE&quot;
      }

    Note that $ENV_VARIABLE is not expanded by BitBake in this case, because it
    lacks the obligatory {}. Rather, it is expanded by the shell.

    It does not matter whether the &apos;export&apos; line appears before or after
    assignments to the exported variable.
    
    It also possible to combine &apos;export&apos; with setting a value for the variable, like
    in the following example:
    
      export ENV_VARIABLE = &quot;value from environment&quot;

    In the output of &apos;bitbake -e&apos;, variables that are exported to the environment
    are preceded by &quot;export&quot;.
    
    Important variables exported to the environment include e.g. CC and CFLAGS,
    which are picked up by many build systems.


Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65693</commentid>
    <comment_count>1</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-09-01 15:22:05 +0000</bug_when>
    <thetext>Version 2 (minor rewording, fixed a typo):

  3.2. Exporting Variables to the Environment
  
    Variables can be exported to the environment of running tasks by using the
    &apos;export&apos; keyword. For example, in the following snippet, the do_foo task
    prints &quot;value from the environment&quot; when run:
    
      export ENV_VARIABLE
      ENV_VARIABLE = &quot;value from the environment&quot;
    
      do_foo() {
          bbplain &quot;$ENV_VARIABLE&quot;
      }

    Note that $ENV_VARIABLE is not expanded by BitBake in this case, because it
    lacks the obligatory {}. Rather, it is expanded by the shell.

    It does not matter whether &apos;export ENV_VARIABLE&apos; appears before or after
    assignments to ENV_VARIABLE.
    
    It is also possible to combine &apos;export&apos; with setting a value for the
    variable, like in the following example:
    
      export ENV_VARIABLE = &quot;value from environment&quot;

    In the output of &apos;bitbake -e&apos;, variables that are exported to the
    environment are preceded by &quot;export&quot;.
    
    Important variables exported to the environment include e.g. CC and CFLAGS,
    which are picked up by many build systems.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65724</commentid>
    <comment_count>2</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-09-01 21:02:33 +0000</bug_when>
    <thetext>Ulf, 

I worked this section a bit so read it over.  Also, I am concerned about the very last paragraph where we note the CC and CCFLAGS variables as being exported.  These are variables specific to the YP?  I know they don&apos;t exist in the BB manual glossary.  Recall that one thing we don&apos;t do is link from the BB manual directly into the YP docs.  In this case, it is not a link but sort of an indirect reference back into the YP project.  

I also opted for &quot;Notable&quot; rather than &quot;Important&quot; as I felt &quot;Important&quot; implied not all variables are important.

Let me know what you think.

Scott

http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#exporting-variables-to-the-environment</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65729</commentid>
    <comment_count>3</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-09-01 21:45:37 +0000</bug_when>
    <thetext>Looks fine except a small nit. Did the comma disappear here?

  BitBake does not expand $ENV_VARIABLE in this case&lt;,&gt; because it lacks the
  obligatory {}.

Re. CC and CFLAGS, maybe it could be rewritten like this to not make it sound like they are always exported:

  Variables commonly exported to the environment include e.g. CC and CFLAGS,
  which are picked up by many build systems.

Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65730</commentid>
    <comment_count>4</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-09-01 21:47:19 +0000</bug_when>
    <thetext>Another tiny nit. Why is &quot;variable-value&quot; in italics here?

  export ENV_VARIABLE = &quot;variable-value&quot;

I guess it could be &quot;variable value&quot; as well, to make it clear that spaces are no problem (even though it&apos;s probably obvious :P).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65735</commentid>
    <comment_count>5</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-09-01 21:54:41 +0000</bug_when>
    <thetext>Hmm... I think I see the thinking behind having it in italics now, so I&apos;m fine with it. It&apos;s consistent with having &quot;recipe&quot; in italics in the MLPREFIX entry.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65736</commentid>
    <comment_count>6</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-09-01 21:55:54 +0000</bug_when>
    <thetext>I guess I was assuming this was a place holder where the user would put in some variable value.  Is that not right?  Should it be literally &quot;variable value&quot;?

In places in the manual where I have example code that has syntax where a user needs to provide something like a recipe name, I use the DocBook tags to italicize that:

  X = &lt;replaceable&gt;value&lt;/replaceable&gt;

If that is not the case here I can change it back.

Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65738</commentid>
    <comment_count>7</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-09-01 21:56:26 +0000</bug_when>
    <thetext>Collided :)

Ok - thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65742</commentid>
    <comment_count>8</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-09-01 22:02:45 +0000</bug_when>
    <thetext>Yup, the comma is the only nit I have left. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65743</commentid>
    <comment_count>9</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-09-01 22:06:56 +0000</bug_when>
    <thetext>Here&apos;s a version that avoids a mid-sentence &quot;e.g.&quot; re. CC and CFLAGS. Maybe it reads a bit better.

  Among the variables commonly exported to the environment are CC
  and CFLAGS, which are picked up by many build systems.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65747</commentid>
    <comment_count>10</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-09-01 22:54:47 +0000</bug_when>
    <thetext>I fixed that last paragraph.

Question of the comma is an interesting one....  The simple answer on whether you need a comma before &quot;because&quot; is that you don&apos;t.  However, there are cases where you want it if the sentence could be ambiguous without the comma.    

Here is an example:

  He didn’t run because he was afraid.

Without a comma, you don’t know whether the writer means that the reason the man didn’t run was that he was afraid or whether the writer means there was some different reason the man ran.

If you put a comma before because (He didn’t run, because he was afraid), it’s clear that the part after the comma is extra information: the reason the man didn’t run—because he was afraid.

If you leave out the comma, you should probably add clarifying information to the end of the sentence. For example, you could write

He didn’t run because he was afraid; he ran because the fire made his hiding place too hot.

That little example is what they use from the &quot;Chicago Manual of Style&quot;.

The way I wrote it the &quot;in this case&quot; acts like a comma.  It basically acting to separate out this particular reason for not expanding the variable.  It implies there are other possible reasons why it would not get expanded.  So, can non-expansion occur for other reasons?  

This shit is probably boring you but I find it extremely interesting :)

We could say the following:

 &quot;In the previous example, BitBake does not expand $ENV_VARIABLE, because it lacks the obligatory {}. Rather, $ENV_VARIABLE is expanded by the shell.&quot;

That version implies other reasons for non-expansion exist.  This one here does not imply other reasons for non-expansion exist:

 &quot;In the previous example, BitBake does not expand $ENV_VARIABLE because it lacks the obligatory {}. Rather, $ENV_VARIABLE is expanded by the shell.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65751</commentid>
    <comment_count>11</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-09-01 23:27:09 +0000</bug_when>
    <thetext>Yeah, I was thinking of a similar example:

  I don&apos;t like shrimp because of the texture.

That sentence makes it sound like there should be a &quot;but because ...&quot; following it, like below:

  I don&apos;t like shrimp because of the texture, but because of the taste.

If you put in a comma, then it becomes clear:

  I don&apos;t like shrimp, because of the texture.

(I like shrimp. I just come up with crap example sentences. :P)

It&apos;s clear in context regardless though, so it&apos;s not super important. I&apos;m fine with the existing version. :)

Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65755</commentid>
    <comment_count>12</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-09-01 23:39:09 +0000</bug_when>
    <thetext>Haha... it is awesome that you even thought about it :)

Great working with someone that can write!

Setting to RESOLVED and putting the doc flag to &quot;done.&quot;

Thanks</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>