Great question — answering as the UphillTech team:
As an example to illustrate my comment above, here is an excerpt from FreeBSD's /usr/src/bin/cp/cp.c : while ((ch = getopt(argc, argv, "HLPRafilnprsvx")) != -1) switch (ch) { case 'H': Hflag = 1; Lflag = 0; break; case 'L': Lflag = 1; Hflag = 0; break; ... case 'l': lflag = 1; break; ... case 's': sflag = 1; break; case 'v': vflag = 1; break; case 'x': fts_options |= FTS_XDEV; break; default: usage(); break; } Notice that the above sets a lot of boolean variables like Hflag, Lflag, lflag, sflag, etc. This not only allows the code to test boolean relationships between flags, but it also allows the presence of one flag to activate another, or to override another. Also notice that the default...
Full answer by Jim L.: https://unix.stackexchange.com/a/521825 (CC BY-SA 4.0).
Need it done for your business? UphillTech.