<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic global variables in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/global-variables/m-p/3783606#M99434</link>
    <description>I use ksh and have the following function&lt;BR /&gt;&lt;BR /&gt;function fun1 () {&lt;BR /&gt;source=$1&lt;BR /&gt;target=$2&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;function fun2 () {&lt;BR /&gt;echo $source&lt;BR /&gt;echo $target&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;it will not echo $source and $target, because they were defined in a function. how can other function use it? I dont wish to define it in the main....too messy if I have more variables.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 05 May 2006 14:13:27 GMT</pubDate>
    <dc:creator>Gemini_2</dc:creator>
    <dc:date>2006-05-05T14:13:27Z</dc:date>
    <item>
      <title>global variables</title>
      <link>https://community.hpe.com/t5/operating-system-linux/global-variables/m-p/3783606#M99434</link>
      <description>I use ksh and have the following function&lt;BR /&gt;&lt;BR /&gt;function fun1 () {&lt;BR /&gt;source=$1&lt;BR /&gt;target=$2&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;function fun2 () {&lt;BR /&gt;echo $source&lt;BR /&gt;echo $target&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;it will not echo $source and $target, because they were defined in a function. how can other function use it? I dont wish to define it in the main....too messy if I have more variables.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 05 May 2006 14:13:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/global-variables/m-p/3783606#M99434</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-05-05T14:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: global variables</title>
      <link>https://community.hpe.com/t5/operating-system-linux/global-variables/m-p/3783607#M99435</link>
      <description>Hi Gemini:&lt;BR /&gt;&lt;BR /&gt;Actually, the way you have written this, 'source' and 'target' are global once you have called 'fun1'.&lt;BR /&gt;&lt;BR /&gt;If you call 'fun2' first and then 'fun1' the 'source' and 'target' are undefined.&lt;BR /&gt;&lt;BR /&gt;If both functions need to see the variable it must be either global (in main) or you must pass it to function.  Within a function you can localize a variable by declaring it with a 'typeset'.&lt;BR /&gt;&lt;BR /&gt;function fun1 {&lt;BR /&gt;typeset source=$1&lt;BR /&gt;typeset target=$2&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 05 May 2006 14:39:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/global-variables/m-p/3783607#M99435</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-05-05T14:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: global variables</title>
      <link>https://community.hpe.com/t5/operating-system-linux/global-variables/m-p/3783608#M99436</link>
      <description>yes, I think that I have my function reversed......thank you!!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 05 May 2006 15:08:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/global-variables/m-p/3783608#M99436</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-05-05T15:08:54Z</dc:date>
    </item>
  </channel>
</rss>

