f



Can't comment out shell's "pipe" character

Here's an oddity, using Script Debugger I can't compile shell code
containing the pipe character when it's commented out:

(*
 find $folder -type f -name '*.txt' |
   while IFS= read -r file
   do
      sed -n '1! G;h;$ p' "$file" > "$NEWDIR/$file"
   done 
*)

however adding a linewise comment to the offending line allows the script to
compile:

(*
--  find $folder -type f -name '*.txt' |
   while IFS= read -r file
   do
      sed -n '1! G;h;$ p' "$file" > "$NEWDIR/$file"
   done 
*)

Is this normal? Does Script Editor do it too? (I don't have it).

Explanation anyone?

-- Gnarlie

0
4/30/2004 1:44:47 PM
comp.sys.mac.system 33446 articles. 2 followers. jfmezei.spamnot (9455) is leader. Post Follow

8 Replies
609 Views

Similar Articles

[PageSpeed] 46

On Fri, 30 Apr 2004 09:44:47 -0400, Gnarlodious wrote
(in article <BCB7B46E.41515%gnarlodiousNULL@VOID.invalid.yahoo.com>):

> Is this normal? Does Script Editor do it too? (I don't have it).
> 
> Explanation anyone?

It seems like a bug in AppleScript's compiler. It happens in 
ScriptEditor too.

-- 
J Brady

0
jbrady (127)
4/30/2004 4:04:04 PM
Gnarlodious <gnarlodiousNULL@VOID.invalid.yahoo.com> wrote:

> Here's an oddity, using Script Debugger I can't compile shell code
> containing the pipe character when it's commented out:
> 
> (*
>  find $folder -type f -name '*.txt' |
>    while IFS= read -r file
>    do
>       sed -n '1! G;h;$ p' "$file" > "$NEWDIR/$file"
>    done 
> *)
> 
> however adding a linewise comment to the offending line allows the script to
> compile:
> 
> (*
> --  find $folder -type f -name '*.txt' |
>    while IFS= read -r file
>    do
>       sed -n '1! G;h;$ p' "$file" > "$NEWDIR/$file"
>    done 
> *)
> 
> Is this normal? Does Script Editor do it too? (I don't have it).
> 
> Explanation anyone?

Explained on p. 109 of my book. m.

-- 
matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/
AppleScript: The Definitive Guide
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Read TidBITS! It's free and smart. http://www.tidbits.com
0
matt231 (2249)
4/30/2004 5:26:23 PM
In article <BCB7B46E.41515%gnarlodiousNULL@VOID.invalid.yahoo.com>,
 Gnarlodious <gnarlodiousNULL@VOID.invalid.yahoo.com> wrote:

> Is this normal? Does Script Editor do it too? (I don't have it).
> 
> Explanation anyone?

Yes:

   (* this | | is a valid comment *)

but:

   (* this | is not a valid comment *)


ISTR reading it in a book once.

p109-110 if I'm not mistaken?

:-)

-- 
Martin
0
bitbucket7 (108)
4/30/2004 11:57:00 PM
Entity Martin spoke thus:

>  (* this | | is a valid comment *)

Oops! Posted that question to the wrong group.
But I'll accept your answer anyway, I just wonder why one pipe is illegal
but two compiles.

-- Gnarlie
http://www.Gnarlodious.com/

0
5/1/2004 12:08:54 AM
On Fri, 30 Apr 2004 20:08:54 -0400, Gnarlodious wrote
(in article <BCB846B4.41BE6%gnarlodiousNULL@VOID.invalid.yahoo.com>):

> But I'll accept your answer anyway, I just wonder why one pipe is illegal
> but two compiles.


In AppleScript the pipe character is used for identifiers, and is used 
to specify that whatever series of characters between two pipe 
characters are one identifier. So you could have the sequence (* inside 
an identifier like this |this is a (* identifier|. So in effect it 
overrides the (* for comments so by having a | in the comments forces to 
compiler to look for a matching | to close the identifier killing the 
closing *) for the comment.

Page 44 of the FREE AppleScript Language guide that you can download 
from apple's site. 

And matt, thanks for nothing, you can shove that book up your greedy 
A$$.

0
5/1/2004 1:17:36 AM
Entity John Drako spoke thus:

> In AppleScript the pipe character is used for identifiers, and is used
> to specify that whatever series of characters between two pipe
> characters are one identifier. So you could have the sequence (* inside
> an identifier like this |this is a (* identifier|. So in effect it
> overrides the (* for comments so by having a | in the comments forces to
> compiler to look for a matching | to close the identifier killing the
> closing *) for the comment.
Got it, thanks. Now that you mention it, I have used that structure to
extract a boolean result without even knowing how it works.
 
> And matt, thanks for nothing, you can shove that book up your greedy
> A$$.
Whoa! Sounds like an XP forum!

-- Gnarlie
http://www.Spectrumology.com
Spectrumology is the science of chaos.


0
5/1/2004 5:16:56 AM
On Sat, 1 May 2004 01:16:56 -0400, Gnarlodious wrote
(in article <BCB88EE7.41C23%gnarlodiousNULL@VOID.invalid.yahoo.com>):

>  
>> And matt, thanks for nothing, you can shove that book up your greedy
>> A$$.
> Whoa! Sounds like an XP forum!

Some people have no class. The decent way of handling this would have 
been to answer the question and then mention that the answer to that 
question and many more are in his book.

Did he really think that no one would answer the question and make him 
look like an ass?

One thing for sure, he has lost a potential sale. I actually was 
thinking of buying his book, but...

0
5/1/2004 12:30:07 PM
Entity John Drako spoke thus:

>  I actually was thinking of buying his book, but...

it doesn't have a "Search" button? 

0
5/1/2004 3:34:59 PM
Reply: