Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I don't want the backslash to escape ...

2 views
Skip to first unread message

cheizer

unread,
May 26, 2005, 11:40:25 AM5/26/05
to
Hello,
I'm trying to do a linsert and it's removing my backlash from my
string.

Here is an example of what i'm doing...

foo = "rm /Users/local/Send\ Registration"
puts [linsert $foo 0 exec]

and here is the result "exec rm {/Users/heizer1/Send Registration}"
eventually 'm going to replace the puts with eval.


thanks,
- Charles

Kaitzschu

unread,
May 26, 2005, 11:51:21 AM5/26/05
to
On Thu, 26 May 2005, cheizer wrote:

> I'm trying to do a linsert and it's removing my backlash from my string.

No it isn't.

> Here is an example of what i'm doing...
>
> foo = "rm /Users/local/Send\ Registration"

You don't have a backslash in your string. You have an escaped space. And
neither are you doing that, assignments are done with [set], not with =.

> puts [linsert $foo 0 exec]
>
> and here is the result "exec rm {/Users/heizer1/Send Registration}"

You see those curly braces? You didn't write those, but Tcl changed your
backslash-escaped-string to a "properly" quoted string. Backslash is still
"there", but it isn't visible. Space has been escaped in both cases.

> eventually 'm going to replace the puts with eval.

That should be no problem, [linsert] gives you a list, and parameter to rm
has been escaped, so eval just destroys that outermost list. I guess and
hope. I try to avoid [eval] because it is sure that somewhere it will rm
all my files due missing listification :)

But your case seems to be fine. Though someone else should check that out.

--
-Kaitzschu
s="TCL ";while true;do echo -en "\r$s";s=${s:1:${#s}}${s:0:1};sleep .1;done

cheizer

unread,
May 26, 2005, 12:16:31 PM5/26/05
to
Sorry,
I pasted in the debug output rather than the code...

It should have read ...
set foo "rm /Users/local/Send\ Registration"

not

foo = "rm /Users/local/Send\ Registration"

thanks, for the info on the result explanation, I dd not realize that
the backslash was invisable.

Thanks,
- charles

Darren New

unread,
May 26, 2005, 12:24:15 PM5/26/05
to
cheizer wrote:
> thanks, for the info on the result explanation, I dd not realize that
> the backslash was invisable.

The backslashisn't "invisible". The "" interpret the backslash inside.
Just like in C, a '\n' is a newline character with no backslash inside
it, in Tcl a "\ " is just a space. If you want to insert a backslash
into a string delimited with double-quotes, use \\, just like in C.

--
Darren New / San Diego, CA, USA (PST)
The samba was clearly inspired
by the margarita.

Brian

unread,
May 26, 2005, 1:37:56 PM5/26/05
to

Carefully form proper lists and you shouldn't have any problems.

set foo [list rm {/Users/local/Send Registration}]


puts [linsert $foo 0 exec]

.
.
.
eval [linsert $foo 0 exec]


Semi off topic. You really should be using [file delete] instead of
[exec rm].

-Brian

cheizer

unread,
May 26, 2005, 7:52:01 PM5/26/05
to
Hi Brian,
thanks for the reply. Yes, I agree about using [file delete] but I have
had problems with it in the past and it also supporting recursive
deletes including directories.

- Charles

Ralf Fassel

unread,
May 27, 2005, 4:08:58 AM5/27/05
to
* "cheizer" <hei...@llnl.gov>

| thanks for the reply. Yes, I agree about using [file delete] but I have
| had problems with it in the past

Which problems?

| and it also supporting recursive deletes including directories.

Use
file delete -force
to delete directories. See documentation for details.

R'

0 new messages