• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can't pipe files to compileHelp
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't pipe files to compileHelp


  • Subject: Re: Can't pipe files to compileHelp
  • From: Andy Lee <email@hidden>
  • Date: Sun, 4 Aug 2002 09:39:46 -0400

At 7:55 AM -0400 8/4/02, Bill Cheeseman wrote:
The compileHelp tool won't accept piped input, and I don't know why. If I
have two files in my current directory named xHelp.rtf and yHelp.rtf, this
command in Terminal generates a file called Help.plist (for use with the
Cocoa NSHelpManager API):

compileHelp -o Help.plist xHelp.rtf yHelp.rtf

But if I generate a list of the two files using ls and pipe it to the
compileHelp command, I'm told I have used the wrong number of parameters:

ls *Help.rtf | compileHelp -o Help.plist


SHORT ANSWER:

It seems to me that instead of piping, the command you want is either...

compileHelp -o Help.plist *Help.rtf

...or:

compileHelp -o Help.plist `ls *Help.rtf`

The latter construct is actually silly as written. I included it in case you were using "ls" as a placeholder for some more complex operation, like:

compileHelp -o Help.plist `scriptThatGeneratesListOfFileNames`

LONG ANSWER (at the risk of yammering when the short answer was enough):

There are three separate Unix programming concepts here:

(1) a program taking piped input
(2) a program taking command-line arguments
(3) the shell expanding arguments

(1) A program processes piped input if it reads from standard input (stdin). In a pure C program this would be done by functions like scanf() and gets(). A program is free to ignore standard input.

(2) A program processes command-line arguments by a completely different mechanism. The command-line arguments show up as an array argument to the program's main() function. The program is free to examine or ignore this array -- independently of whether it processes standard input.

The pipe you tried would have worked if compileHelp had been smart enough to check its argument list, realize there were no filenames in it, and get its list of filenames from standard input instead. I don't know if compileHelp is supposed to have this feature, but apparently it doesn't.

(3) Each command in your script runs within a process called a shell. The shell does a bit of preprocessing before executing the command. The preprocessing includes expanding filenames that contain wildcards, and it includes executing things within backticks and substituting the results for the backticked expression. So either...

compileHelp -o Help.plist *Help.rtf

...or...

compileHelp -o Help.plist `ls *Help.rtf`

...becomes...

compileHelp -o Help.plist xHelp.rtf yHelp.rtf

...before the shell executes compileHelp.

--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Can't pipe files to compileHelp
      • From: Bill Cheeseman <email@hidden>
References: 
 >Can't pipe files to compileHelp (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: Accessor methods and (auto)release <Memory trail>
  • Next by Date: Framework problem
  • Previous by thread: Can't pipe files to compileHelp
  • Next by thread: Re: Can't pipe files to compileHelp
  • Index(es):
    • Date
    • Thread