[comp.sys.mac.programmer] A problem with MPW....

dorourke@polyslo.CalPoly.EDU (David M. O'Rourke) (08/18/89)

  I wrote a shell script that will list all of the directories in a 
certain pre-defined directory and make menu equivilants to do a lot of
work when I choose that menu.  Now I didn't want the menu options to have
the colon's in their names so I decided to use 'translate' to translate 
the colon's to nothings, and I add the colon's by hand later in the
script.

  Now for the problem......

  files -d | translate : ''

  works fine, and I get a list of what I want.

  but when I make it part of a for loop to loop across all of the directory 
names

  for dir_name in `files -d | translate : ''`
    [do_some stuff]
  end

  translate dies complaining that
 "# MPW.Pipe.# isn't of type TEXT, terminate and screw you "

  that's not the exact error message but apparently if you try and
execute the command inbetween some back quotes translate doesn't like
the pipe file type and dies, but if you just do the command directly in
the shell it works fine.

  Anyone have any ideas, short of me writting my own translate that won't
care about the file type.

  Apple???
-- 
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\|/////////////////////////////////////////
David M. O'Rourke____________________|_____________dorourke@polyslo.calpoly.edu
|  God doesn't know, he would have never designed it like that in the first   |
|_ place. ____________________________________________________________________|

earleh@eleazar.dartmouth.edu (Earle R. Horton) (08/18/89)

In article <13644@polyslo.CalPoly.EDU> dorourke@polyslo.CalPoly.EDU
	(David M. O'Rourke) writes:
...
>  for dir_name in `files -d | translate : ''`
>    [do_some stuff]
>  end
>
>  translate dies complaining that
> "# MPW.Pipe.# isn't of type TEXT, terminate and screw you "
>
     Try:

for dir_name in `files {MPW} -d > {MPW}MPW.mypipe; translate < option-d
	{MPW}MPW.mypipe : ''`
echo {dir_name}		# Yep, works!
end

>  Anyone have any ideas, short of me writting my own translate that won't
>care about the file type.

     Show the computer who's boss (you) by defining your own pipe
file.  Use a unique name for the file, and remember to delete it when
done if you don't want it hanging around.

Earle R. Horton

dorourke@polyslo.CalPoly.EDU (David M. O'Rourke) (08/18/89)

earleh@eleazar.dartmouth.edu (Earle R. Horton) writes:
>     Show the computer who's boss (you) by defining your own pipe
>file.  Use a unique name for the file, and remember to delete it when
>done if you don't want it hanging around.

  Thankyou for your solution, I was already doing just what you suggested
but I was looking more for the bug fix.  I take it my error is reproducible
on other systems.

  Again I thank Mr. Horton for taking the time to respond, now I'm wondering
why this "bug" is in translate, has anyone else found a similar bug in
any of the other MPW tools??

>Earle R. Horton
-- 
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\|/////////////////////////////////////////
David M. O'Rourke____________________|_____________dorourke@polyslo.calpoly.edu
|  God doesn't know, he would have never designed it like that in the first   |
|_ place. ____________________________________________________________________|

keith@Apple.COM (Keith Rollin) (08/21/89)

In article <13653@polyslo.CalPoly.EDU> dorourke@polyslo.CalPoly.EDU (David M. O'Rourke) writes:
>earleh@eleazar.dartmouth.edu (Earle R. Horton) writes:
>>     Show the computer who's boss (you) by defining your own pipe
>>file.  Use a unique name for the file, and remember to delete it when
>>done if you don't want it hanging around.
>
>  Again I thank Mr. Horton for taking the time to respond, now I'm wondering
>why this "bug" is in translate, has anyone else found a similar bug in
>any of the other MPW tools??

Obligatory "It's not a bug, it's a feature." Actually, more of a poorly
documented limitation. If I recall the circumstances correctly, you are trying
to use the same Pipe file at the same time (ie, using a pipe command withing
the single backquotes). This, MPW cannot do.

I may have some of the problem mixed up, but I think that's the jist/gyst/what-
ever of it. Even so, I've only seen it happen in conjunction with the 
translate tool (though I've never tried it with any other).

------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions

earleh@eleazar.dartmouth.edu (Earle R. Horton) (08/22/89)

In article <34167@apple.Apple.COM> keith@Apple.COM (Keith Rollin) writes:
>In article <13653@polyslo.CalPoly.EDU> dorourke@polyslo.CalPoly.EDU (David M. O'Rourke) writes:
>>earleh@eleazar.dartmouth.edu (Earle R. Horton) writes:
>>>     Show the computer who's boss (you) by defining your own pipe
>>>file.  Use a unique name for the file, and remember to delete it when
>>>done if you don't want it hanging around.
>>
>>  Again I thank Mr. Horton for taking the time to respond, now I'm wondering
>>why this "bug" is in translate, has anyone else found a similar bug in
>>any of the other MPW tools??
>
>Obligatory "It's not a bug, it's a feature." Actually, more of a poorly
>documented limitation. If I recall the circumstances correctly, you are trying
>to use the same Pipe file at the same time (ie, using a pipe command withing
>the single backquotes). This, MPW cannot do.
>
     Actually, that has nothing whatever to do with it.  MPW Shell creates
multiple pipe files in this situation, and translate gets the second
or third one as its input.  Then it says:

### translate: "hd:mpw:MPW.Pipe-2" is not a TEXT file.

     Translation: "Screw you."  Someone has specifically coded the
translate tool to reject any input file whose type is not TEXT.  MPW
Pipe files are type '    ' and creator '    ', even though they are created
by the Shell and almost always contain text of some sort.

     I don't understand the rationale behind this, and I hate to
condemn something when not in possession of all the facts, so let me
say this regarding the matter:  "This appears stupid."

Earle R. Horton