I applied this exact function on our Jenkins example. The way I did this is to use the "This function with parameters" parameter to add an assembly parameter that you can use to determine if commands should be executed.
On the job configuration page, select “This assembly is parameterized”, then “Add selection parameter” (you can also use any other type of parameter, just update the IF example below). Enter a name (no spaces or special characters), no and yes options (upper default - default) and optional description. 
Now you can add the “Execute shell” build step, which checks the AreYouSure value to see if you want to complete the complete build. If the value is not yes, exit with code 1, so Jenkins reports a build error. All steps below the check will not be completed if the user does not select "yes".
Here is the code to check the value of a variable:
if [ "${AreYouSure}" = "yes" ] then

Bryce source share