Re: Stupid bash question

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

 



Ralf Corsepius wrote:
It would be quite easy to provoke:

Assume a program to change its behavior depending on whether it's called
"X", "Y" or "Z". Now rename it to "A" or try to use copy of X under the
name "myX".

Which behavior will "A" or "myX" expose? The results will be random.

Not necessarily. It would depend on how the program was coded.

Sorry, you're going to have to come up with a more practical example
before I'm convinced.

I do agree with you though that argv[0] is not under the programmer's
control and so it should be treated defensively, just as any other
external input should be. I suppose that could be the intent behind the
word "depend" in the guideline.

If you read it like a lawyer, it only says that the program should not
/depend/ on the name to decide the behavior. Does that mean "not depend
at all" or "not depend solely" on the name?

You could meet the letter of the guideline if the program used its name
as /one way/ to adjust it's behavior, but not the /only/ way.

These positive guidelines:
 * The program should have a defined behavior if argv[0] has an
unexpected value,
 * All of the program's behaviors should be accessible by options, and
 * The options have precedence over argv[0],
are consistent with the negative guideline, without killing the whole
concept.

IMO, the fact you haven't seen such effects only is the result of only
very few programs applying "change behavior upon program name" ;)

I'm no systems whiz, but I've used the technique myself on a number of
occasions and found it handy. I'm going to need something substantial
before I abandon a useful technique. GNU is probably worried about some
larger issues that I don't care so much about.

Here's one possibility: writing a program to run across systems that may
do some ugly name munging with executables, like, oh, calling it
"test.exe" or something. Are there any primitive systems like that still
around?

<Joe



--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux