/British, Scottish or Irish English/

Is this sentence grammatically correct?

"You shall be safe, as long as you stay here"

If it's not, under which circumstances "shall" can be used instead of "will"?

Thanks vm,
Shall/will is a very difficult issue in BrE, for those "not to the manner born," as Fowler says, especially if you want to follow the classical/prescriptive rules.
Read this chapter:
H.W. Fowler (1858–1933). The King’s English
Normally, for plain-future (rule 3 in that chapter), as in your case, you should say:
I/we shall
you, he/she, they will
I am willing to be corrected by my British counterpartsEmotion: smile
Students: Are you brave enough to let our tutors analyse your pronunciation?
Thank you very much! (Especially for that link)
Shall is used when the speaker has a high level of influence over the events.