Re: linebreak in a shell script; was Re: What's wrong with this call to zip?
Re: linebreak in a shell script; was Re: What's wrong with this call to zip?
- Subject: Re: linebreak in a shell script; was Re: What's wrong with this call to zip?
- From: Christopher Nebel <email@hidden>
- Date: Thu, 28 Feb 2008 09:35:15 -0800
On Feb 27, 2008, at 5:54 PM, Dmitry Markman wrote:
AFAIK
by default do shell converts unix style eoln (0x0A) to mac style
(0x0D)
That's only for the output, and you can make it not do that using
"without altering line endings". (I wish that was the default, but by
the time I realized that the translation was even there, people had
already written scripts that relied on it. Needless to say, I didn't
write it.)
On Feb 27, 2008, at 5:20 PM, Mark J. Reed wrote:
On Wed, Feb 27, 2008 at 7:05 PM, tom wible <email@hidden>
wrote:
return is not newline
That depends.
property newline : "
"
I think that would be clearer if you defined it as "ascii character
10".
Not to mention the fact that some editors may silently mangle the
literal linefeed to a carriage return. Script Editor in Leopard has
an option to make it show as "\n", so there's no ambiguity even with a
literal string.
The term "newline" does not mean "linefeed", however. It means
"whatever the local convention is for delimiting lines in text
files", be it carriage return, linefeed, both in sequence, the start
of a new rdbms row, whatever.
That depends on whose definitions you're using -- the C++ standard
uses "new-line" and "linefeed" as synonyms in one place -- but Mark's
basic point is correct: there's the general concept of a "line break",
and different languages and file formats have different ideas about
exactly what bytes constitute a valid line break. Therefore, if
you're going to jump between languages (such as with "do shell
script"), you need to be aware of the local conventions. For shell
scripts, that's ASCII 0x0a, which you can get in AppleScript using
"\n", "ASCII character 10" (deprecated in Leopard), or, in Leopard,
"linefeed" or "character id 10".
--Chris Nebel
AppleScript Engineering
P.S.: The C9X draft I have makes an interesting dodge on this topic.
It defines \n, \r, etc. in terms of their intended effect, but
specifically says that their actual representation is implementation-
dependent, and even says that the internal (in-memory) and external
(on-disk) representations may be different.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden