Escape Apostrophes in 'Do Shell Script'
Escape Apostrophes in 'Do Shell Script'
- Subject: Escape Apostrophes in 'Do Shell Script'
- From: Jay Young <email@hidden>
- Date: Wed, 5 Nov 2003 23:01:14 -0600
I've been looking in the Archives on this subject, but haven't found
what I'm looking for at the moment. 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. For example, if I run this Perl
code in AS:
-------------------
set x to do shell script "perl -e 'print \"What's Up?\";'"
display dialog x
-------------------
It gives me this error :
"sh: -c: line 1: unexpected EOF while looking for matching `\"'
sh: -c: line 2: syntax error: unexpected end of file"
Is there a way to 'escape' the apostrophe in "what's" so that it's not
messing with the apostrophes around the code? The only solution I've
come up with is to change any apostrophes to ASCII character 213
(option-shift-}) and then run it through the 'do shell script'.
I did figure out something else too that did work with the example
above:
-------------------
set x to do shell script "perl -e 'print \"What'\\''s Up?\";'"
display dialog x
-------------------
--> What's Up?
but I'm not too thrilled with it (mainly because I'm not quite sure why
it works).
Thanks.
Jay
_______________________________________________
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.