• 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: Escape Apostrophes in 'Do Shell Script'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Escape Apostrophes in 'Do Shell Script'


  • Subject: Re: Escape Apostrophes in 'Do Shell Script'
  • From: Jay Young <email@hidden>
  • Date: Thu, 6 Nov 2003 23:20:14 -0600

Just wanted to say thanks to Christopher, Emmanuel and Laine for
clearing me up on this. I went ahead and wrote this handler so that
when I'm passing a variable (that might contain an apostrophe) from an
AS dialog default answer into a Perl 'do shell script', this seems to
take care of it for me:

-------------------------
set x to (display dialog "Please enter some text:" default answer "")'s
text returned

if x contains "'" then set x to fixApostrophe for x

to fixApostrophe for x
set text item delimiters to "'"
set fixedA to x's text items
set text item delimiters to "'\\''"
set fixedA to fixedA as string
set text item delimiters to ""
fixedA
end fixApostrophe
-------------------------

I appreciate your help and am very glad to be part of this List with so
many people who are willing to take the time to help others out.
Thanks again! :-)

Jay

--

Emmanuel wrote:

> At 11:01 PM -0600 05/11/03, Jay Young wrote:
>> Basically, I'm wondering if
>> there's a way to escape apostrophes in a 'do shell script' in case a
>> word contains an apostrophe itself.
>
> I think that Christopher Nebel is sleeping, so:
>
> ---------------------------
> quoted form of "What's Up?"
> --> "'What'\\''s Up?'"
> ---------------------------
>
> Emmanuel

==============================

Christopher wrote:

> Yes, I was. I'm up now. (Yawn. Stretch.)
>
> The usual answer to this sort of thing is "use the 'quoted form'
> property", but the original question is actually more complicated than
> that...
>
> ...To fix this, you need to
> emulate what you'd have to do in the shell, which is this:
>
> perl -e 'print "What'\''s Up?";'
>
> Or, in AppleScript with the extra backslashes:
>
> do shell script "perl -e 'print \"What'\\''s Up?\";'"...
_______________________________________________
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.

  • Prev by Date: Re: Bug (?) with 'open for access' in Panther
  • Next by Date: applescript-users digest, Vol 3 #2137 - 9 msgs ( -Reply)
  • Previous by thread: Re: Escape Apostrophes in 'Do Shell Script'
  • Next by thread: Entourage window resizing
  • Index(es):
    • Date
    • Thread