Most riders do not carry a spare cable on regular short rides, and while good quality cables rarely break, especially when replaced at their recommended service intervals, it happens. Here is a quick fix that will get you home if you break a shifter cable on the trail (particularly in hilly areas like Wadi Degla, where a broken rear shifter cable means getting stuck in a tall gear for the rest of the way home, which in turn means a lot of walking!)
1) Pick a gear on your cassette that will be adequate for the ride back home and manually shift the rear derailleur (by pushing the derailleur body inwards and to the rear) to place your chain on that gear.
2) Find a small rock (or any suitable object) to jam under the outer arm of the derailleur, as shown in the above picture, to prevent the spring from pulling the derailleur back to the smallest gear due to lack of cable tension.
3) Ride home! (and remember to replace that broken cable!)
Obviously, the Shimano XT Shadow derailleur shown in this picture makes this fix somewhat easy due to the open design of the outer arm, but most modern derailleurs from Shimano and SRAM have a similar outer arm design.