Given some unknown input, how do you tell which variables are being substituted into a (s)printf
statement?
printf("%s %s", "a", "b"); // both used
printf("%s", "a", "b"); // only the first one used
printf('%1$s %1$s', "a", "b"); // " "
printf('%s %1$s', "a", "b"); // " "
printf('%1$s %s %1$s', "a", "b"); // " "
printf('%2$s', "a", "b"); // only the second one used.
Checking the resultant string for the presence of the first or second variables won't help, because they could have the same value.
In my own situation, there is only ever 2 variables that could be substituted, and I need to know whether the second one is used or not.