Change
#!/bin/bash
export var1="value1"
export var2="value2"
export var3="value3"
program
into
#!/bin/bash
if [ "$1" != "debug" ]; then
export var1="value1"
fi
export var2="value2"
export var3="value3"
program
The first command line argument to your script will be available in $1, and if that is not the string debug, export the var1 environment variable.
The #!-line could optionally be changed into #!/bin/sh as the script (as written above) does not use any bash-specific features.
A variation of the above which does it differently with an array, without actually setting the variables in the script itself (only for the program when starting it):
#!/bin/bash
if [ "$1" != "debug" ]; then
vars=( var1="value1" )
fi
vars+=( var2="value2" var3="value3" )
env "${vars[@]}" program
or, for /bin/sh,
#!/bin/sh
mode=$1
set -- var2="value2" var3="value3"
if [ "$mode" != "debug" ]; then
set -- var1="value1" "$@"
fi
env "$@" program
if [[ $1 != debug ]]; then export var1; fi