Re: Big bug in shell scripting in Applescript
Re: Big bug in shell scripting in Applescript
- Subject: Re: Big bug in shell scripting in Applescript
- From: "Zavatone, Alex" <email@hidden>
- Date: Fri, 05 Aug 2011 08:29:29 -0700
- Acceptlanguage: en-US
- Thread-topic: Big bug in shell scripting in Applescript
Axel, what is does is add a \n every time it is called. Not to each line, but only to the last line.
Did you run the script that I pasted which shows this?
On Aug 5, 2011, at 3:50 AM, Axel Luttgens wrote:
> Le 5 août 2011 à 00:08, Zavatone, Alex a écrit :
>
>> Think I found a big bug in sed or shell scripting in AppleScript.
>>
>> Copy the code below, run and look at the output.
>>
>> \n gets appended to the last line of the return string every time this is run.
>>
>> […]
>
> Hello Alex,
>
> As always, trying to convey a problem thru a very simplified example is the best way to go:
>
> do shell script "sed 's:^a::'<<<'abcdefg'" without altering line endings
> --> "bcdefg
> "
> So, yes, a linefeed appears to be appended.
>
> Let's thus try in terminal:
>
> luttgens$ sed 's:^a::'<<<'abcdefg'
> bcdefg
> luttgens$
>
> A linefeed as well thus.
>
> Looking at sed's man page:
>
> Normally, sed cyclically copies a line of input, not including its termi-
> nating newline character, into a pattern space, (unless there is some-
> thing left after a ``D'' function), applies all of the commands with
> addresses that select that pattern space, copies the pattern space to the
> standard output, appending a newline, and deletes the pattern space.
>
> Clearly, sed is devised to handle a stream of input lines and to produce a stream of output lines accordingly to standard unix conventions.
>
> No bug in sed, nor in shell scripting.
>
> Now, about AppleScript's "do shell script" and its "altering line endings":
>
> Should the do shell script command change all line endings in the
> command output to Mac-style and trim a trailing one? For example,
> the result of do shell script "echo foo; echo bar" is "foo\rbar",
> not the "foo\nbar\n" that the shell script actually returned.
>
> Default Value:
> true
>
> Again, your results agree with a documented behavior.
>
> As a result, it would tend to believe there is no big bug at all… ;-)
>
> HTH,
> Axel
>
> _______________________________________________
> 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
This email message and any attachments are for the sole use of the intended recipient(s) and may contain information that is proprietary to U.S. Foodservice, Inc and/or its subsidiaries or otherwise confidential or legally privileged. If you have received this message in error, please notify the sender by reply, and delete all copies of this message and any attachments. If you are the intended recipient you may use the information contained in this message and any files attached to this message only as authorized by U.S. Foodservice. Files attached to this message may only be transmitted using secure systems and appropriate means of encryption, and must be secured using the same level password and security protection with which the file was provided to you. Any unauthorized use, dissemination or disclosure of this message or it's attachments is strictly prohibited.
_______________________________________________
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