This is a very good question, and you are smart to raise it. Both your sentences are indeed grammatical,³ which is why you often find both sorts. In a nutshell, the one with would expresses a proposition that is less likely than the one that uses will.
That’s because backshifting is used to indicate this distancing from expectation or reality. It's the same effect as seen with the verb wish, where this also happens: I wish it would rain or I wish you would have called me.
The reason you may not find these in your “grammar books” is because learning materials for non-native speakers always grossly simplify the possible combinations down to a very few reduced but common forms. They do this because they are trying to make sure learners do not accidentally stumble over combinations that actually are ungrammatical.³
But despite the best of intentions, by committing this facile reduction they neglect — egregiously to my mind — to teach learners that English does not have have some tiny and frozen set of viable combinations of constructions in the paired halves the way some other languages do.
Many combinations are completely grammatical,³ yet mean something different in a subtly nuanced way. These they do not teach, because the many real possibilities are too confusing for quick classification by learners.
But it does learners a disservice to pretend that these few possibilities are the only the ones that exist or the only ones which are grammatical.³ They do not even reflect actual usage by native speakers, as Christian Jones and Daniel Waller observe in their journal entry from the English Language Teaching Journal titled “If only it were true: the problem with the four conditionals”¹ when they write:
It is clear that a division of conditionals into the zero, first, second, and third categories does not adequately reflect actual usage.
If you actually look at corpus occurrences, as they have done, you find that many of the modal combinations frequently found in speech and writing by native speakers are simply not explained to beginners. By attempting to deflect learners from common errors, these errors of omission lead to even more confusion. And this can do genuine harm, as explained below.
This is hardly the first or earliest time this observation has been made in the professional literature. In the April 1988 edition of ELT Journal, David Maule has a paper titled “￼￼￼ ‘Sorry, if he comes, I go’: teaching conditionals”² in which he writes (bold emphasis mine):
Michael Lewis, in his recent book, The English Verb (Lewis 1986), makes the
point that to indulge in artificial simplification is merely to store up
trouble for the future. The damage is compounded when the simplified
explanation is backed up by a few well-vetted examples, inconvenient
‘exceptions’ being actively suppressed.
When these two tendencies are unleashed on this area we run the risk of our
students coming to believe that either the standard Type 1 structure is the
only way of dealing with real non-past conditions, or, perhaps at a later
stage, that it is the ‘correct’ way, and that all other examples
encountered are colloquial, or dialectal, or instances of sub-standard
usage. Incidentally, it is worth noting that if the collection I made is
in any way representative, suppression of other structures would involve
ruling out something like 90 percent of real non-past conditionals.
Our resident linguist Professor John Lawler sums this up here in this comment (bold emphasis again my own):
They're just mostly-safe combinations of if..then clause types; they're not tenses and they don't cover every possibility. Linguists don't have names for the Zero-thru-N types you mentioned, and not for any others that some textbook writer might dream up, either. Generally there is a hypothetical clause of some sort and a conclusion clause of some sort; but there are hundreds of possible combinations, and they rarely have to do with tense -- too much depends on the type of condition and its results, which can vary all over the lot.
There really are hundreds of possibilities, not just some number you can count on one hand. Just in one part alone, all of these can occur given the right situation:
- If he were to confess
- If he confessed
- If he did confess
- If he had confessed
- If he has confessed
- If he confesses
- If he will confess
- If he shall confess
- If he would confess
- If he should confess
- If he might confess
- If he must confess
- If he dare confess
- If he need confess
Many of those also admit inversion possibilities that skip the if entirely:
- Were he to confess
- Should he confess
- Had he confessed
- Did he but confess
- Should he have confessed
(Of course, inversion like this is a much more formal style, one found mainly in literature and formal speeches, not in casual conversation.)
I think you can see how listing out all those would risk quickly overcoming learners, and would be even more likely to do so were one to go enumerating all possibilities for the other clause as well.
Those are just a few, and most of them mean different things. Some are of course much more common than others, but it is easy for a native speaker to craft various reference frames in which all of them are “grammatical”.³
It is, unfortunately, also easy for non-native speakers to concoct sentences whose paired clause for those would not be grammatical at all. That is the only reason that learners are taught so tiny a subset of valid conditional propositions: because they might otherwise create combinations that do not make sense to a native speaker.
Here are other examples closer to your original:
If he does show up, I wouldn’t let him in.
If he does show up, you shouldn’t let him in.
If he really wants something, he wouldn’t just take it. I know him well, and I’m sure he’d ask nicely.
If sentences like these are not in your grammar books, then you need better grammar books, because they are completely normal sentences in English.
The best thing learners should take away from all this is that there exist hundreds more valid combinations used daily by native speakers than were ever mentioned in your grammar books.
ELT Journal 65:1 pp 24–32 (2011), Oxford University Press, doi: 10.1093/elt/ccp101.
ELT Journal 42:2 pp 117–123 April 1988, Oxford University Press, doi: 10.1093/elt/42.2.117.
Remember that grammatical means nothing more than something that sounds ok to a native speaker. All of the would-be rules you are taught are merely after-the-fact explanations that attempt to describe the things a native speaker does or does not think sounds ok to them. What rules there may be all derive from observations of actual language as it is used by native speakers. This is not math.
The opposite word, ungrammatical, is simply the negation of that, therefore meaning something which a native speaker would think does not sound right.