Shit: Do I Hug Other Guy Goodbye, Or Just Handshake/Pat-On-Back Thing?

“I sort of tentatively made a move to hug him. But at the same exact time, he put his hand out for a shake. I corrected at the last minute, and tried to add a pat on the back as if the shake-pat was all I had in mind all along. But I think he saw through it. Now what the hell are we supposed to do next time? Am I supposed to downgrade and not offer a hug? How will I even withstand his eye contact?"