Shifter cable replacement*pics of damage* new problem?

The cable abd sheathe need to be fixed in length. To have a opening in the sheathe allowing the cable to go in and out of it yields the same result as having the one end of the sheathe unattached or not anchored. Hope that makes sense.
I've seen several similar posts. A popular cure is routing a much longer cable up over around and back again like a loop.