Q:

BASH:Passing arguments from one shebang to another

I have two scripts. 
temp.sh
#! /usr/bin/foo
echo "$@"

foo
#! /usr/bin/bash
source "$@"

This works  except in the following case when temp.sh has a parameter in its shebang as follows.
temp.sh
#! /usr/bin/foo -x
echo "$@"

This makes it problematic. 
/root/foo: line 4: source: -x: invalid option
source: usage: source filename [arguments]

Is there anyway I can pass this -x(or for that matter any and all parameters) passed to temp.sh's shebang to foo's shebang? 

A:

If you want to consume the first argument and pass it to the shell interpreter when it matches a specific set of patterns, you can do that yourself:
# treat first argument of -x or -v as intended for the shell interpreter
case $1 in -[xv]) set "$1"; shift;; esac

source "$@"

