Hello.
As of lately I have several times gotten into situations, where I have tried to pass more command text to do shell script than it can take. According to Apple’s tn 2061 it can take about 262.000 bytes if the user hasn’t a too big environment.
There are different ways of over coming this limitation, sometimes a rewrite of parts of you script to a Unix script might do the trick, that is however not feasible in every situation.
Here are some “back of the envelope” calculations to check if we are within the bounds, they are for western languages-
We deal with Unicode text where each character is represented by minimum two and maximum 4 bytes if I remember correctly. I estimate the usage of more than two bytes per character characters to always be less than 2% of the contents of a given text file.
The length of a text is returned in characters.
If the length of a text multiplied by two and divided by 0,98 is less than 261.000, then one should be able to send the text to the do shell script command.
If not, one would have to split up the text in chuncks, and pass the chuncks to the do shell script command, with the following assembly of the output.
on okCommandSize( txtCommandBuffer )
if (length of txtCommandBuffer) * 2 / 0,98 is greater than 261000 then
return false
else
return true
end if
end okCommandSize