• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Big bug in shell scripting in Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Big bug in shell scripting in Applescript


  • Subject: Re: Big bug in shell scripting in Applescript
  • From: Axel Luttgens <email@hidden>
  • Date: Fri, 05 Aug 2011 10:50:25 +0200

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

  • Follow-Ups:
    • Re: Big bug in shell scripting in Applescript
      • From: "Zavatone, Alex" <email@hidden>
References: 
 >Big bug in shell scripting in Applescript (From: "Zavatone, Alex" <email@hidden>)

  • Prev by Date: Re: Plain text editor
  • Next by Date: Re: Big bug in shell scripting in Applescript
  • Previous by thread: Re: Big bug in shell scripting in Applescript
  • Next by thread: Re: Big bug in shell scripting in Applescript
  • Index(es):
    • Date
    • Thread