shell programming / aliasing / set -f

Here's my opportunity.... I want to turn off the * expansion, execute the shell script and have it see the arguement with the * and not all the filenames, and then set +f once the script is executed.

1) I have an alias set as follows:

alias scp='set -f; /opt/dir1/dir2/script.sh ; set +f'

of course this fails due to the way aliasing works.

scp /dir/dir2/*     the * does not get passed correctly to the binary because of the alias being set and the "; set \+f" being aliased... so...

I do:

alias scp='set -f; /opt/dir1/dir2/shell.sh'

and thus

scp /dir/dir2/*

works perfectly because the set -f is performed at the current shell level before executing /opt/dir1/dir2/shell.sh thus what is passed to my script is the string "/dir/dir2/*" and the splat is not expanded... so

All's well except that the set -f remains in effect. Is anyone away of how I can get the 'set +f' executed once the script is finished?

I don't think there's an elegant and straightforward way to do this. But what if the second command in the alias were a function instead? Something like

alias scp='set -f; myscp'
myscp () {
  /opt/dir1/dir2/shell.sh "$@"
  set +f
}

Seems to work at least in Bash, for what it's worth.