I have a script in which some of the commands need to be run as sudo. I have seen it asserted that running sudo inside scripts is a bad idea, and that is is better to run the whole script as sudo (and then possibly modify sudoers for convenience, as described here).
I have thought about it, and can't actually see any reason not to run sudo commands inside scripts. Assuming the script and its directory are both owned by root, and therefore unadulterated, I can't see any difference, from a security point of view. (And even if it were, running the whole script as sudo would be no less dangerous). Am I missing something here?