title: bash run function with different user
body: <p>Would be possible to run a custom bash function with different priviledges?</p>
  
  <pre><code>#!/bin/bash
  function RunStefano() {
       while [ 1 ]; do
           echo "Ciao, ´/usr/bin/whoami´"
           sleep 10;
       done &amp;
  }
  export -f RunStefano;
  echo "Welcome, ´/usr/bin/whoami´"
  sudo -u stefano -c "RunStefano"
  </code></pre>
  
  <p>If I run this script with 'root' user, I want to receive as output:</p>
  
  <pre><code>Welcome, root
  Ciao, stefano
      (...)
  Ciao, stefano
  </code></pre>
  
  <p>Would it be possibile?</p>