Thursday, April 10, 2008

Do you know how ensum handle command-line parameters?

After dig into its source code (~/gg/kf/blsum/ensum.f), I got that this is a trick related to system shell. For a command like "ensum 2 sum val *.org", when call the program ensum, shell (say, csh) just pass all the file names matching "*.org" into the ensum as command-line parameters. Thus, the final calling syntax may look like:
ensum 2 sum val 1.org 2.org 3.org ...

Then, how to know how many files are there?
Just check count the number of non-blank parameters. (For example, it could be supposed that there maybe maximum 10000 *.org files.)

No comments: