Re: How do I escape a question mark (?)
Re: How do I escape a question mark (?)
- Subject: Re: How do I escape a question mark (?)
- From: Christopher Nebel <email@hidden>
- Date: Mon, 5 Aug 2002 16:11:52 -0700
I'm not sure what you're talking about, Deivy, because unless I'm
missing something, I get the same results for both scripts. Are you
sure you're not being fooled by the result window again? For example,
the result of the first script (using "do shell script") appears as
this:
{{"b", "\\c", "\\d", "\\\\e"}, {"b", "c", "d", "\\e"}}
However, because this is source form, every backslash appears as two,
so the resulting strings are actually...
b, \c, \d, \\e b, c, d, \e
...which is correct. When debugging this sort of thing, you may find
it helpful to run the script using osascript with no options (or -sh if
you're feeling pedantic). That displays the result in "human-readable"
form, which doesn't escape backslashes. (It also doesn't display list
braces, so it's not useful for some things, but there you are.)
--Chris Nebel
AppleScript Engineering
On Monday, August 5, 2002, at 01:49 PM, Deivy Petrescu wrote:
There is a bug in do shell script or something wrong with the sh
implementation. Chris, you are right that AS does whatever it is
supposed to do when one writes set a to "\\b", for instance, but once
it gets passed to do shell
script it is passed as \\b. The difference in behavior between do
shell script, do script with command plus the possible bug with do
shell script can be seen running the following scripts:
set a to "\\b"
set b to "\\\\c"
set c to "\\\\\\d"
set d to "\\\\\\\\e"
set l1 to do shell script "echo " & a
set m1 to do shell script "echo " & a
log a
set l2 to do shell script "echo " & b
set m2 to do shell script "eval echo " & b
log b
set l3 to do shell script "echo " & c
set m3 to do shell script "eval echo " & c
log c
set l4 to do shell script "echo " & d
set m4 to do shell script "eval echo " & d
log d
{{l1, l2, l3, l4}, {m1, m2, m3, m4}}
and
set a to "\\b"
set b to "\\\\c"
set c to "\\\\\\d"
set d to "\\\\\\\\e"
tell application "Terminal"
set l1 to do script with command "echo " & a
set m1 to do script with command "eval echo " & a
log a
set l2 to do script with command "echo " & b
set m2 to do script with command "eval echo " & b
log b
set l3 to do script with command "echo " & c
set m3 to do script with command "eval echo " & c
log c
set l4 to do script with command "echo " & d
set m4 to do script with command "eval echo " & d
log d
end tell
_______________________________________________
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.