AIUI
[LAWS]20.12 OFFSIDE AT THE SCRUM
(a) When the scrum is set , the scrum half not throwing the ball into the scrum must take up a position either at the same side of the scrum as the scrum half throwing in the ball or behind the offside line defined for other players.[/LAWS]
i.e. before the ball is thrown in, he must either stand to the left of the scrum half throwing in, or he has to be 5m back behind the hindmost foot of the hindmost player in his own scrum
[LAWS](c) When a team has won the ball in a scrum, the scrum half of the opposing team is offside if that scrum half steps in front of the ball with either foot while the ball is still in the scrum. This scrum-half may not move into the space between the flanker and No. 8 when following the ball through the scrum.[/LAWS]
i.e. he cannot follow the opposing SH into the "pocket"
[LAWS](d) The scrum half whose team does not win possession of the ball must not move to the opposite side of the scrum and overstep the offside line. For that scrum half that runs through the hindmost foot of that player’s team in the scrum.[/LAWS]
i.e. he cannot follow the ball by switching to the other side of the scrum.
[LAWS](e) The scrum half whose team does not win possession of the ball must not move away from the scrum and then remain in front of the offside line. For that scrum half that runs through the hindmost foot of that player’s team in the scrum.[/LAWS]
i.e. while the ball is still in the scrum, he can go as far as he likes left and right so long as he remains behind the hindmost foot of his hindmost player (his offside line). If he wishes to remain in front of his offside line, he must remain within 1m of the scrum.