It wasn't perfect - almost nothing about South African cricket is these days - but they kept their knockout hopes alive with a scratchy but ultimately successful chase against their favourite opponents. This was South Africa's sixth successive win over Sri Lanka and their best, because it came against the backdrop of serious pressure.

Although defeat would not have guaranteed they would be knocked out, it would have made progressing to the semi-finals complicated. It may still not be straightforward but this team has now proved to itself that it can overcome adversity. They have done it twice this week, which could otherwise have descended into (even more) chaos following what most in the squad have described as their toughest time in international cricket.

The drama, in case you missed it, started on Monday night when the CSA board resolved to issue a directive to the men's national team instructing them all to take a knee before every game. The players found out on Tuesday morning, five hours before their match against West Indies, and by the time they reached the ground, that Quinton de Kock had decided he would not comply and withdrew from the XI. Two days later, de Kock apologised and U-turned, and yesterday Keshav Maharaj said the squad was more united than ever.

As they took the field against Sri Lanka, they were determined to show it. They stood with their arms around each other as they sung the national anthem, the first time they have done that at this tournament and, in the time of Covid-19, the first time they have done that in a while. They all took a knee. And then they worked together to end Sri Lanka's most profitable partnership, the 40-run second-wicket stand between Pathum Nissanka and Charith Asalanka. Crucially, they kept Sri Lanka under 150, thanks mostly to Tabraiz Shamsi, who has now taken more T20I wickets in a calendar year than anyone else, and a strangling effort at the end of the opposition innings.

"We have won these kinds of moments more often than we have lost them. That's a huge positive. We are here to win the World Cup"
Tabraiz Shamsi

Dwaine Pretorius is not the perfect death bowler. In fact, South Africa entered this tournament without an obvious candidate for the final overs but chose Pretorius despite his domestic record, which does not immediately suggest he would be a good candidate. Prior to this tournament, Pretorius had bowled 36 overs at the death, taken 18 wickets and had an economy of 10.38. In the three matches he has had so far, he has bowled 5.4 overs at the death, taken six wickets, and has an economy of 8.64. His use of the slower ball, in particular, has been impressive. Today, two of them brought him wickets and he finished with his second three-wicket haul at this tournament.

"If we had to give out an award for Scholar of the Team, it would be Dwaine Pretorius," Shamsi said at the post-match press conference. "He wants to make sure he is well prepared and he is always working with our analyst. We can't speak enough about the job he did for us at the end. The game was so close. It's turned out that he has become our death bowling specialist and he has done a great job."

Temba Bavuma is not the perfect T20 player - and most of the criticism around him is about scoring too slowly - but he is, as de Kock put it, "a flipping amazing leader" and this was the week he showed it in word and deed. His run-a-ball 46 anchored a wobbly chase but there will still be pressure on him to get going. Bavuma faced 29 balls before he found the boundary and was on 37 off 42 when he hit the six over midwicket that took his strike rate to 100. He took that as his cue to finish the innings and tried to hit Wanindu Hasaranga over cow corner but picked out a fielder to become the filling in the hat-trick sandwich. Bavuma berated himself and told the television broadcast he wanted to see the chase through. "I took on that responsibility. I felt someone had to take it to the end."

David Miller is not the perfect finisher. Although his ability to clear the rope is reputed, he has not won a game for South Africa recently and he was fast going to run out of partners. Luckily Kagiso Rabada "always has the shot of the day", as Shamsi put it, and the classy six he smashed over long-off cut through some of the stress of the situation but not all of it. "I was a bit tense," Bavuma admitted. "But I had a lot of confidence in the fact that David was there. He hasn't done that for us in a while but he has got the most beautiful swing."

This is not a perfect South African team, and their batting has big holes. Today was an example of where their top-heavy approach could backfire. Like it or not, there simply isn't room to play what are essentially five openers - de Kock, Reeza Hendricks, Bavuma, Aiden Markram and Rassie van der Dussen - in the top six, but because South Africa lack middle-order options, it's a combination they are stuck with for now.

Shamsi is comfortable with it, because "there's different batters that put their hands up and take the team to victory", but against stronger opposition, like Australia (as we saw in the Super 12s opener) and England, who are yet to come, it may not work. More worryingly, the only middle-order batter they seem to want to use, Miller, has a hamstring niggle. Shamsi, too, is nursing a groin strain. South Africa's next match is against Bangladesh on Tuesday so there isn't much time to recover.

But these are all problems that tournament-winning teams, who are often imperfect, overcome and Shamsi believes South Africa will do the same. "We have won these kinds of moments more often than we have lost them. That's a huge positive," Shamsi said. "We are here to win the World Cup."

Firdose Moonda is ESPNcricinfo's South Africa correspondent