I have a program which generates large lists… like around 4000 lines…
and when I use this:
ignoring case
set nl to (ASCII character 10)
tell (a reference to my text item delimiters)
set {old_delim, contents} to {contents, nl}
set {the_list, contents} to {"
" & the_list, old_delim}
end tell
end ignoring
return paragraphs of (do shell script "echo " & (quoted form of the_list) & " | sort -f")
I get:
the command exited with non - zero status (255)
… but yet if the list is smaller, I don’t… So how do I deal with this problem? Should I just sort every 1000 lines and set that to a new list?
If I’m reading technote 2065 correctly (and I may not be) you can’t send values greater than 255k to the shell directly from AppleScript. Consider saving the list to a file and have the shell sort that instead.
Q: How long can my command be, really? A: Calling do shell script creates a new sh process, and is therefore subject to the system’s normal limits on passing data to new processes: the arguments (in this case, the text of your command plus about 40 bytes of overhead) and any environment variables may not be larger than kern.argmax, which is currently 262,144 bytes. Because do shell script inherits its parent’s environment (see the next question), the exact amount of space available for command text depends on the calling environment. In practical terms, this comes out to somewhat more than 261,000 bytes, but unusual environment settings might reduce that substantially.