Alex, The two of use agree on most issues here.
Heuristics, no. Pre-existing parsers, yes. I prefer argp, because it includes documentation. We do disagree n argv[0] Using argv[0] to determine behavior definitely used to be standard, back in the pre-Linux days. mv and ln, I believe were the same binary. But not any more. And today, in memory-limited environments, busybox uses this technique. It makes sense there. Please name modern examples which do not result from limited memory. Using argv[0] leaves you in a situation where copying an executable to a new name results in different behavior. In your example, if I copied xfreerdp to xfreerdp-new, then the behavior would be different, even though the name is almost the same. And it using argv[0] violates the GNU standard, something you should do only when there is a good reason for doing so. ----- Original Message ----- From: Alex Bligh <a...@alex.org.uk> To: Kevin Dalley <kdal...@vmware.com> Cc: Alex Bligh <a...@alex.org.uk>, Stephen Dowdy <sdo...@ucar.edu>, freerdp-devel@lists.sourceforge.net Sent: Tue, 04 Dec 2012 11:46:34 -0800 (PST) Subject: Re: [Freerdp-devel] Why is there a change in the command line interface? On 4 Dec 2012, at 18:07, Kevin Dalley wrote: > Please don't use argv[0] to determine the behavior. This is confusing. > > It should be possible to make a link to a program and have it behave in > the same way as the original program. > > Also, it violates the GNU standards. > > http://www.gnu.org/prep/standards/html_node/User-Interfaces.html#User-Interfaces Opinion from someone who has had exposure to reading the code but not writing it, and tripped over the current CLI. In my opinion using argv[0] to influence program operation is perfectly reasonable and a lot of linux utilities do it (for better or worse). Moreover, the appropriate standard should be POSIX not GNU here. I don't believe there is a POSIX requirement not to do this (but POSIX standards are full of surprises). I understand some people consider it hacky, but it does permit the following which is what I'd recommend. If invoked as xfreerdp, use a command line interface as close as possible to the current one. I know this needs work, having tried to find my way through the homebrew parser to backport stuff. I would suggest moving to the getopt_long which has support everywhere, and at least is a known quantity. I do not think there is anything freerdp does which would not possible using getopt_long, and there might be bugs which could be fixed by a refactor (from memory the parsing of certain security parameters depends on other parameters, which means as they are parsed in order, the effect is dependent upon the ordering of parameters - this could be fixed by recording parameters prior to interpreting them). If invoked as [something else], use a CLI more friendly for windows users, be that borrowed from mstsc or otherwise. Heuristics that rely on the presence or absence of slashes or minus signs are bound to fail as filenames on windows can begin with minus signs and file names (well, paths) on linux can begin with slashes. So don't try and guess, use something that can never be ambiguous (i.e. argv[0]). I believe on some non-POSIX platforms it may not be possible to determine the value of argv[0], but I doubt xfreerdp will run there anyway. -- Alex Bligh ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Freerdp-devel mailing list Freerdp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freerdp-devel