Edit: I'm a bit slow. So here is another solution:
Do you just want to run the script as another user?
If thats the case I only found a workaround for this:
# First call? Switch user.
if [ "$1" != "-nouserswitch" ] ; then
exec su $username -c "/home/dom/Temp/test.sh -nouserswitch"
So you basically run your script twice. The first time to execute the script as another user. The second time (with the "-nouserswitch" argument) to actually run your script.
This solution does only work if you need the user switch at the very beginning of the script.