title: Is there a way to prevent sourced scripts in POSIX sh from running anything in global scope?
body: <p>I'm making a thing which has to source
  a POSIX shell script (<strong>NOT BASH</strong>) as its configuration
  file, but it should only have definitions of variables,
  functions and comments, nothing else like running something in
  global scope, so I wonder, is there a way to
  stop users from being able to run any code globally,
  only in functions and stuff?</p>
  <p>I mean:</p>
  <ul>
  <li>main.sh</li>
  </ul>
  <pre class="lang-sh prettyprint-override"><code># ...
  # . in POSIX sh has the same meaning as &quot;source&quot; in bash
  . /etc/something/config.sh
  echo &quot;$(get_hello), $ME&quot;
  # ...
  </code></pre>
  <ul>
  <li>/etc/something/config.sh</li>
  </ul>
  <pre class="lang-sh prettyprint-override"><code>#!/usr/bin/env sh
  
  # This one is fine
  export ME='Some user'
  hello='hi :)'
  
  # This is fine too
  get_hello() {
      echo '$hello'
  }
  
  # This should error or be ignored
  echo 'I should not be executed/should throw an error'
  </code></pre>
  <p>Any way to do this?</p>