tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Updating old scripts ... #1 /usr/sbin/ypinit



I am doing a run through the NetBSD sources looking for old scripts
that contain vartious poor mechanisms...

My current target is the old "getopt" which we should remove from
everywhere (not the getopt binary, of course, but everything that
actually uses it in our tree.)

Fortunately, the most common reference to getopt is in a comment in
a whole bunch of ltmain.sh scripts ...

	/* very simple arg parsing; don't want to rely on getopt */

which is a very reasonable attitude, and doesn't require any work.

But there are a few others - the first to hit my radar is ypinit.sh  (which
also contains a few old style uses of test which are trivial to fix.)

The issue with ypinit is that its usage, and its man page, both document it
as:

	usage:  ypinit -c [domainname] [-l server1,...,serverN]
	        ypinit -m [domainname] [-l server1,...,serverN]
	        ypinit -s master_server [domainname] [-l server1,...,serverN]

	The `-c' flag sets up a YP client, the `-m' flag builds a master YP
	server, and the `-s' flag builds a slave YP server.  When building a
	slave YP server, `master_server' must be an existing, reachable YP server.

That is, the optional domainname arg comes before the optional -l server,...
arg, and there are signs in the script that that may have once been how it
operated.

As best I can tell, using getopt that is impossible, and doesn't work, and the
script needs to be run as

	ypinit -c  [-l server1,...,serverN]  [domainname]

(and similar using -m or -s instead of -c).   If I do a simple change from 
getopt to getopts the same will remain true.

If we want to keep the documented usage, then we can revert to a pre-getopt[s]
arg parsing method.

Which is preferred?

It is hard to imagine that it makes much difference, ypinit is only intended 
to be run by a sysadmin, not by other scripts (anything like that would
simply do what ypinit does, rather than running ypinit to do it) and humans
can normally easily adapt to changes like this (in our case, I assume, must
have adapted) but there's always a chance that there'[s some human-emulation
software somewhere (like py-anita if I understand that correctly) which is
designed to act in place of a human for autmated testing, and similar) which
actually run ypinit, and perhaps expect the original usage to remain.

Does anyone know of anything like that?

kre



Home | Main Index | Thread Index | Old Index