The author points out that the meaning has changed over time from the initial meaning of "superuser" to "switch user", due to feature creep.
http://harmful.cat-v.org/cat-v/
I think `su` is pretty good as-is, but sudo has a bit of feature creep. For example, I don't think these belong in sudo (taken from Linux):
-e: edit something
-l: list allowed/forbidden commands
-p: change prompt
Ideally, sudo would just run as root and su would just switch users. Then instead of:
sudo -u some_user cmd
You'd do this instead:
sudo su -c "cmd" some_user
Su only does one thing (switch users, -c for one-off cmd) and sudo only does one thing (change to root). Currently, both "sudo -u some_user cmd" and "sudo su -c some_user cmd" accomplish basically the same thing, which is a sign of feature creep.
This could be a simple wrapper script around sudo, but that could require entering the password twice.
(hint: C doesn't support exceptions)
You could use longjmp/setjmp but those have a lot of the same issues that people claim goto has. In fact worse in several ways, since while goto makes it hard to follow the program flow, longjmp makes it /impossible/.
Only if you don't use it tastefully. It can be a nice way to bail out of a recursive function with an error code, which is precisely how I've used it. Really, it looks exactly the same as a try ... catch block in that C++/Java/C# language everyone's on about now.
What about this snippet:
if (error_return) {
printf("My error");
return;
}
Clearer than a goto, no? And see, no exceptions ma'!(Oh yeah, and longjmp/setjmp are the worst ideas in the world...)