Re: Q: echo | sed -- Solved!
Re: Q: echo | sed -- Solved!
- Subject: Re: Q: echo | sed -- Solved!
- From: Nigel Smith <email@hidden>
- Date: Tue, 18 May 2004 16:57:30 +0100
On 18/5/04 14:50, "Gnarlodious" <email@hidden> wrote:
>
I'm sending a bug report even though this may be a shell issue.
Gnarlie,
You may be barking up the wrong tree here.
I don't think anyone else has mentioned this, but I think it was the *echo*
command that was failing in your original script, not sed.
Check the output of the following:
----------
set oldTIDs to AppleScript's text item delimiters
set theNums to {"1", "2", "3", "4", "5", "6"}
set delims to {ASCII character 13, ASCII character 10}
repeat with eachItem in delims
set AppleScript's text item delimiters to contents of eachItem
set someLines to theNums as text
try
log (do shell script "echo " & someLines)
on error errMsg
log errMsg
end try
end repeat
set AppleScript's text item delimiters to oldTIDs
----------
On your replaceLines, using Mac delimiters you are echoing a single line
into sed, which replaces the 2 with the 8, spits it back out as a single
line, which your editor then displays as multiple lines because of the Mac
line breaks.
Using Unix delimiters you send nothing to sed, because of the echo error,
which returns nothing.
On deleteRange, using Mac delimiters, you again echo a single line into sed.
From my (very slight) understanding of sed, the "d" option deletes the
addressed *line* and, since there is only one line, the output is ""
Using Unix delimiters, the echo again errors, as above.
Using "quoted form" as you pass the string in has the same behaviour as
above for the Mac-delimited strings. But suddenly the Unix delimited strings
*will* work with echo (since the entire string, with returns, becomes a
single argument), you get the same input as you did with the Unix-based text
file, so you get the same output.
Different behaviour in the different editors is down to them using different
line endings when you hit "return" in mid-string.
That's my theory -- but I'm prepared to be shot down by those more
Unix-savvy than I am (which means almost everyone!).
Later,
Nigel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.