a2p
accept
access
acct
addftinfo
addr2line
adjtime
afmtodit
after
aio_cancel
aio_error
aio_read
aio_return
aio_suspend
aio_waitcomplete
aio_write
alias
aliases
alloc
anvil
append
apply
apropos
ar
array
as
asa
asn1parse
at
atq
atrm
attemptckalloc
attemptckrealloc
authlib
authtest
autopoint
awk
b64decode
b64encode
basename
batch
bc
bdes
bell
bg
bgerror
biff
big5
binary
bind
bindkey
bindtags
bindtextdomain
bio
bitmap
blowfish
bn
bootparams
bootptab
bounce
brandelf
break
breaksw
brk
bsdiff
bsdtar
bsnmpd
bspatch
bthost
btsockstat
buffer
builtin
builtins
bunzip2
button
byacc
bzcat
bzegrep
bzfgrep
bzgrep
bzip2
c2ph
c89
c99
ca
cal
calendar
canvas
cap_mkdb
case
cat
catch
catman
cc
cd
cdcontrol
chdir
checkbutton
checknr
chflags
chfn
chgrp
chio
chkey
chmod
chown
chpass
chroot
chsh
ci
ciphers
ckalloc
ckdist
ckfree
ckrealloc
cksum
cleanup
clear
clipboard
clock
clock_getres
clock_gettime
clock_settime
close
cmp
co
col
colcrt
colldef
colors
colrm
column
comm
command
compile_et
complete
compress
concat
config
connect
console
continue
core
courierlogger
couriertcpd
cp
cpan
cpio
cpp
creat
crl
crontab
crunchgen
crunchide
crypt
crypto
csh
csplit
ctags
ctm
ctm_dequeue
ctm_rmail
ctm_smail
cu
cursor
cursors
cut
cvs
date
dbiprof
dbiproxy
dc
dcgettext
dcngettext
dd
dde
default
defer
deliverquota
des
destroy
devfs
df
dgettext
dgst
dh
dhparam
dialog
diff
diff3
dig
dir
dirent
dirname
dirs
discard
disktab
dngettext
do
domainname
done
dprofpp
dsa
dsaparam
dtmfdecode
du
dup
dup2
eaccess
ec
ecdsa
echo
echotc
ecparam
ed
edit
editrc
ee
egrep
elf
elfdump
elif
else
enc
enc2xs
encoding
end
endif
endsw
engine
enigma
entry
env
envsubst
eof
eqn
err
errno
error
errstr
esac
ethers
euc
eui64
eval
event
evp
ex
exec
execve
exit
expand
export
exports
expr
extattr
extattr_delete_fd
extattr_delete_file
extattr_get_fd
extattr_get_file
extattr_set_fd
extattr_set_file
f77
false
famm
famx
fblocked
fbtab
fc
fchdir
fchflags
fchmod
fchown
fcntl
fconfigure
fcopy
fdescfs
fdformat
fdread
fdwrite
fetch
fg
fgrep
fhopen
fhstat
fhstatfs
fi
file
file2c
fileevent
filename
filetest
find
find2perl
finger
flex
flock
flush
fmt
focus
fold
font
fontedit
for
foreach
fork
format
forward
fpathconf
frame
from
fs
fstab
fstat
fstatfs
fsync
ftp
ftpchroot
ftpusers
ftruncate
futimes
g711conv
gb2312
gb18030
gbk
gcc
gcore
gcov
gdb
gencat
gendsa
genrsa
gensnmptree
getconf
getdents
getdirentries
getdtablesize
getegid
geteuid
getfacl
getfh
getfsstat
getgid
getgroups
getitimer
getlogin
getopt
getopts
getpeername
getpgid
getpgrp
getpid
getppid
getpriority
getresgid
getresuid
getrlimit
getrusage
gets
getsid
getsockname
getsockopt
gettext
gettextize
gettimeofday
gettytab
getuid
glob
global
gmake
goto
gperf
gprof
grab
grep
grid
grn
grodvi
groff
groff_font
groff_out
groff_tmac
grog
grolbp
grolj4
grops
grotty
group
groups
gunzip
gzcat
gzexe
gzip
h2ph
h2xs
hash
hashstat
hd
head
help2man
hesinfo
hexdump
history
host
hostname
hosts
hosts_access
hosts_options
hpftodit
http
hup
i386_get_ioperm
i386_get_ldt
i386_set_ioperm
i386_set_ldt
i386_vm86
iconv
id
ident
idprio
if
ifnames253
ifnames259
image
imapd
incr
indent
indxbib
info
infokey
inode
install
instmodsh
interp
intro
introduction
ioctl
ipcrm
ipcs
ipf
ipftest
ipnat
ippool
ipresend
issetugid
jail
jail_attach
jobid
jobs
join
jot
kbdcontrol
kbdmap
kcon
kdestroy
kdump
kenv
kevent
keycap
keylogin
keylogout
keymap
keysyms
kgdb
kill
killall
killpg
kinit
kldfind
kldfirstmod
kldload
kldnext
kldstat
kldsym
kldunload
klist
kpasswd
kqueue
kse
kse_create
kse_exit
kse_release
kse_switchin
kse_thr_interrupt
kse_wakeup
ktrace
label
labelframe
lam
lappend
last
lastcomm
lastlog
lchflags
lchmod
lchown
ld
ldap
ldapadd
ldapcompare
ldapdelete
ldapmodify
ldapmodrdn
ldappasswd
ldapsearch
ldapwhoami
ldd
leave
less
lesskey
lex
lgetfh
lhash
libnetcfg
library
limit
limits
lindex
link
linprocfs
linsert
lint
lio_listio
list
listbox
listen
lj4_font
lkbib
llength
lmtp
ln
load
loadfont
local
locale
locate
lock
lockf
log
logger
login
logins
logname
logout
look
lookbib
lorder
lower
lp
lpq
lpr
lprm
lptest
lrange
lreplace
ls
lsearch
lseek
lset
lsort
lstat
lsvfs
lutimes
lynx
m4
madvise
magic
mail
maildiracl
maildirkw
maildirmake
mailq
mailx
make
makeinfo
makewhatis
man
manpath
master
mc
mcedit
mcview
md2
md4
md5
mdc2
memory
menu
menubar
menubutton
merge
mesg
message
mincore
minherit
minigzip
mkdep
mkdir
mkfifo
mkimapdcert
mklocale
mknod
mkpop3dcert
mkstr
mktemp
mlock
mlockall
mmap
mmroff
modfind
modfnext
modnext
modstat
moduli
more
motd
mount
mprotect
mptable
msdos
msdosfs
msgattrib
msgcat
msgcmp
msgcomm
msgconv
msgen
msgexec
msgfilter
msgfmt
msggrep
msginit
msgmerge
msgs
msgunfmt
msguniq
mskanji
msql2mysql
msync
mt
munlock
munlockall
munmap
mv
myisamchk
myisamlog
myisampack
mysql
mysqlaccess
mysqladmin
mysqlbinlog
mysqlcheck
mysqld
mysqldump
mysqld_multi
mysqld_safe
mysqlhotcopy
mysqlimport
mysqlshow
mysql_config
mysql_fix_privilege_tables
mysql_zap
namespace
nanosleep
nawk
nc
ncal
ncplist
ncplogin
ncplogout
neqn
netconfig
netgroup
netid
netstat
networks
newaliases
newgrp
nex
nfsstat
nfssvc
ngettext
nice
nl
nm
nmount
nohup
nologin
notify
nroff
nseq
nslookup
ntp_adjtime
ntp_gettime
nvi
nview
objcopy
objdump
objformat
ocsp
od
onintr
open
openssl
opieaccess
opieinfo
opiekey
opiekeys
opiepasswd
option
options
oqmgr
pack
package
packagens
pagesize
palette
pam_auth
panedwindow
parray
passwd
paste
patch
pathchk
pathconf
pawd
pax
pbm
pcre
pcreapi
pcrebuild
pcrecallout
pcrecompat
pcrecpp
pcregrep
pcrematching
pcrepartial
pcrepattern
pcreperform
pcreposix
pcreprecompile
pcresample
pcretest
perl
perl56delta
perl58delta
perl561delta
perl570delta
perl571delta
perl572delta
perl573delta
perl581delta
perl582delta
perl583delta
perl584delta
perl585delta
perl586delta
perl587delta
perl588delta
perl5004delta
perl5005delta
perlaix
perlamiga
perlapi
perlapio
perlapollo
perlartistic
perlbeos
perlbook
perlboot
perlbot
perlbs2000
perlbug
perlcall
perlcc
perlce
perlcheat
perlclib
perlcn
perlcompile
perlcygwin
perldata
perldbmfilter
perldebguts
perldebtut
perldebug
perldelta
perldgux
perldiag
perldoc
perldos
perldsc
perlebcdic
perlembed
perlepoc
perlfaq
perlfaq1
perlfaq2
perlfaq3
perlfaq4
perlfaq5
perlfaq6
perlfaq7
perlfaq8
perlfaq9
perlfilter
perlfork
perlform
perlfreebsd
perlfunc
perlglossary
perlgpl
perlguts
perlhack
perlhist
perlhpux
perlhurd
perlintern
perlintro
perliol
perlipc
perlirix
perlivp
perljp
perlko
perllexwarn
perllinux
perllocale
perllol
perlmachten
perlmacos
perlmacosx
perlmint
perlmod
perlmodinstall
perlmodlib
perlmodstyle
perlmpeix
perlnetware
perlnewmod
perlnumber
perlobj
perlop
perlopenbsd
perlopentut
perlos2
perlos390
perlos400
perlothrtut
perlpacktut
perlplan9
perlpod
perlpodspec
perlport
perlqnx
perlre
perlref
perlreftut
perlrequick
perlreref
perlretut
perlrun
perlsec
perlsolaris
perlstyle
perlsub
perlsyn
perlthrtut
perltie
perltoc
perltodo
perltooc
perltoot
perltrap
perltru64
perltw
perlunicode
perluniintro
perlutil
perluts
perlvar
perlvmesa
perlvms
perlvos
perlwin32
perlxs
perlxstut
perror
pfbtops
pftp
pgrep
phones
photo
pic
pickup
piconv
pid
pipe
pkcs7
pkcs8
pkcs12
pkg_add
pkg_check
pkg_create
pkg_delete
pkg_info
pkg_sign
pkg_version
pkill
pl2pm
place
pod2html
pod2latex
pod2man
pod2text
pod2usage
podchecker
podselect
poll
popd
popup
posix_madvise
postalias
postcat
postconf
postdrop
postfix
postkick
postlock
postlog
postmap
postqueue
postsuper
pr
pread
preadv
printcap
printenv
printf
proc
procfs
profil
protocols
prove
proxymap
ps
psed
psroff
pstruct
ptrace
publickey
pushd
puts
pwd
pwrite
pwritev
qmgr
qmqpd
quota
quotactl
radiobutton
raise
rand
ranlib
rcp
rcs
rcsclean
rcsdiff
rcsfile
rcsfreeze
rcsintro
rcsmerge
read
readelf
readlink
readonly
readv
realpath
reboot
recv
recvfrom
recvmsg
red
ree
refer
regexp
registry
regsub
rehash
remote
rename
repeat
replace
req
reset
resolver
resource
return
rev
revoke
rfcomm_sppd
rfork
rhosts
ripemd
ripemd160
rlog
rlogin
rm
rmd160
rmdir
rpc
rpcgen
rs
rsa
rsautl
rsh
rtld
rtprio
rup
ruptime
rusers
rwall
rwho
s2p
safe
sasl
sasldblistusers2
saslpasswd2
sbrk
scache
scale
scan
sched
sched_getparam
sched_getscheduler
sched_get_priority_max
sched_get_priority_min
sched_rr_get_interval
sched_setparam
sched_setscheduler
sched_yield
scon
scp
script
scrollbar
sdiff
sed
seek
select
selection
semctl
semget
semop
send
sendbug
sendfile
sendmail
sendmsg
sendto
services
sess_id
set
setegid
setenv
seteuid
setfacl
setgid
setgroups
setitimer
setlogin
setpgid
setpgrp
setpriority
setregid
setresgid
setresuid
setreuid
setrlimit
setsid
setsockopt
settc
settimeofday
setty
setuid
setvar
sftp
sh
sha
sha1
sha256
shar
shells
shift
shmat
shmctl
shmdt
shmget
showq
shutdown
sigaction
sigaltstack
sigblock
sigmask
sigpause
sigpending
sigprocmask
sigreturn
sigsetmask
sigstack
sigsuspend
sigvec
sigwait
size
slapadd
slapcat
slapd
slapdn
slapindex
slappasswd
slaptest
sleep
slogin
slurpd
smbutil
smime
smtp
smtpd
socket
socketpair
sockstat
soelim
sort
source
spawn
speed
spinbox
spkac
splain
split
squid
squid_ldap_auth
squid_ldap_group
squid_unix_group
sscop
ssh
sshd_config
ssh_config
stab
startslip
stat
statfs
stop
string
strings
strip
stty
su
subst
sum
suspend
swapoff
swapon
switch
symlink
sync
sysarch
syscall
sysconftool
sysconftoolcheck
systat
s_client
s_server
s_time
tabs
tail
talk
tar
tbl
tclsh
tcltest
tclvars
tcopy
tcpdump
tcpslice
tcsh
tee
tell
telltc
telnet
term
termcap
terminfo
test
texindex
texinfo
text
textdomain
tfmtodit
tftp
then
threads
time
tip
tk
tkerror
tkvars
tkwait
tlsmgr
tmac
top
toplevel
touch
tput
tr
trace
trafshow
trap
troff
true
truncate
truss
tset
tsort
tty
ttys
type
tzfile
ui
ul
ulimit
umask
unalias
uname
uncomplete
uncompress
undelete
unexpand
unhash
unifdef
unifdefall
uniq
units
unknown
unlimit
unlink
unmount
unset
unsetenv
until
unvis
update
uplevel
uptime
upvar
usbhidaction
usbhidctl
users
utf8
utimes
utmp
utrace
uudecode
uuencode
uuidgen
vacation
variable
verify
version
vfork
vgrind
vgrindefs
vi
vidcontrol
vidfont
view
virtual
vis
vt220keys
vwait
w
wait
wait3
wait4
waitpid
wall
wc
wget
what
whatis
where
whereis
which
while
who
whoami
whois
window
winfo
wish
wm
write
writev
wtmp
x509
xargs
xgettext
xmlwf
xstr
xsubpp
yacc
yes
ypcat
ypchfn
ypchpass
ypchsh
ypmatch
yppasswd
ypwhich
yyfix
zcat
zcmp
zdiff
zegrep
zfgrep
zforce
zgrep
zmore
znew
_exit
__syscall
 
FreeBSD/Linux/UNIX General Commands Manual
Hypertext Man Pages
interp
 
interp(n)		     Tcl Built-In Commands		     interp(n)



NAME
       interp - Create and manipulate Tcl interpreters

SYNOPSIS
       interp option ?arg arg ...?


DESCRIPTION
       This  command  makes  it  possible to create one or more new Tcl inter-
       preters that co-exist with the creating interpreter in the same	appli-
       cation.	 The  creating	interpreter  is  called the master and the new
       interpreter is called a slave.  A  master  can  create  any  number  of
       slaves, and each slave can itself create additional slaves for which it
       is master, resulting in a hierarchy of interpreters.

       Each interpreter is independent from the others: it has	its  own  name
       space  for commands, procedures, and global variables.  A master inter-
       preter may create connections between its slaves  and  itself  using  a
       mechanism  called  an  alias.   An alias is a command in a slave inter-
       preter which, when invoked, causes a command to be invoked in its  mas-
       ter  interpreter  or in another slave interpreter.  The only other con-
       nections between interpreters are through  environment  variables  (the
       env  variable), which are normally shared among all interpreters in the
       application. Note that the name space for  files  (such	as  the  names
       returned by the open command) is no longer shared between interpreters.
       Explicit commands are provided to share files and  to  transfer	refer-
       ences to open files from one interpreter to another.

       The interp command also provides support for safe interpreters.	A safe
       interpreter is a slave whose functions have been greatly restricted, so
       that  it is safe to execute untrusted scripts without fear of them dam-
       aging other interpreters or the application's environment. For example,
       all  IO	channel creation commands and subprocess creation commands are
       made inaccessible to safe interpreters.	See  SAFE  INTERPRETERS  below
       for  more  information  on  what  features are present in a safe inter-
       preter.	The dangerous functionality  is  not  removed  from  the  safe
       interpreter;  instead,  it is hidden, so that only trusted interpreters
       can obtain access to it. For a detailed explanation of hidden commands,
       see  HIDDEN  COMMANDS, below.  The alias mechanism can be used for pro-
       tected communication (analogous to  a  kernel  call)  between  a  slave
       interpreter  and  its  master.	See  ALIAS INVOCATION, below, for more
       details on how the alias mechanism works.

       A qualified interpreter name is a proper Tcl lists containing a	subset
       of its ancestors in the interpreter hierarchy, terminated by the string
       naming the interpreter in its immediate master. Interpreter  names  are
       relative  to  the interpreter in which they are used. For example, if a
       is a slave of the current interpreter and it has a slave a1,  which  in
       turn  has  a  slave  a11, the qualified name of a11 in a is the list a1
       a11.

       The interp command,  described  below,  accepts	qualified  interpreter
       names as arguments; the interpreter in which the command is being eval-
       uated can always be referred to as {} (the empty list or string).  Note
       that  it  is  impossible to refer to a master (ancestor) interpreter by
       name in a slave interpreter except through aliases. Also, there	is  no
       global  name by which one can refer to the first interpreter created in
       an application.	Both restrictions are motivated by safety concerns.

THE INTERP COMMAND
       The interp command is used to  create,  delete,	and  manipulate  slave
       interpreters,  and  to share or transfer channels between interpreters.
       It can have any of several forms, depending on the option argument:

       interp alias srcPath srcToken
	      Returns a Tcl list whose elements are  the  targetCmd  and  args
	      associated  with	the alias represented by srcToken (this is the
	      value returned when the alias was created; it is	possible  that
	      the  name  of  the source command in the slave is different from
	      srcToken).

       interp alias srcPath srcToken {}
	      Deletes the alias for srcToken in the slave interpreter  identi-
	      fied by srcPath.	srcToken refers to the value returned when the
	      alias was created;  if the source command has been renamed,  the
	      renamed command will be deleted.

       interp alias srcPath srcCmd targetPath targetCmd ?arg arg ...?
	      This command creates an alias between one slave and another (see
	      the alias slave command below for  creating  aliases  between  a
	      slave  and  its  master).   In this command, either of the slave
	      interpreters may be anywhere in the  hierarchy  of  interpreters
	      under  the interpreter invoking the command.  SrcPath and srcCmd
	      identify the source of the alias.  SrcPath is a Tcl  list  whose
	      elements	select a particular interpreter.  For example, ``a b''
	      identifies an interpreter b, which is a slave of interpreter  a,
	      which  is  a  slave  of the invoking interpreter.  An empty list
	      specifies the interpreter invoking the  command.	 srcCmd  gives
	      the  name  of a new command, which will be created in the source
	      interpreter.  TargetPath and targetCmd specify a	target	inter-
	      preter and command, and the arg arguments, if any, specify addi-
	      tional arguments to targetCmd which are prepended to  any  argu-
	      ments  specified	in the invocation of srcCmd.  TargetCmd may be
	      undefined at the time of this call, or it may already exist;  it
	      is  not  created	by  this  command.  The alias arranges for the
	      given target command to be invoked  in  the  target  interpreter
	      whenever	the  given  source  command  is  invoked in the source
	      interpreter.  See ALIAS INVOCATION below for more details.   The
	      command  returns	a  token  that uniquely identifies the command
	      created srcCmd, even if the command is renamed  afterwards.  The
	      token may but does not have to be equal to srcCmd.

       interp aliases ?path?
	      This  command returns a Tcl list of the tokens of all the source
	      commands for aliases defined in the  interpreter	identified  by
	      path.  The  tokens  correspond  to  the values returned when the
	      aliases were created (which may not be the same as  the  current
	      names of the commands).

       interp create ?-safe? ?--? ?path?
	      Creates  a  slave  interpreter identified by path and a new com-
	      mand, called a slave command. The name of the slave  command  is
	      the  last  component  of path. The new slave interpreter and the
	      slave command are created in the interpreter identified  by  the
	      path  obtained  by  removing  the  last component from path. For
	      example, if path is a b c then a new slave interpreter and slave
	      command named c are created in the interpreter identified by the
	      path a b.  The slave command may be used to manipulate  the  new
	      interpreter  as described below. If path is omitted, Tcl creates
	      a unique name of the form interpx, where x is  an  integer,  and
	      uses  it for the interpreter and the slave command. If the -safe
	      switch is specified (or if the  master  interpreter  is  a  safe
	      interpreter),  the  new  slave  interpreter will be created as a
	      safe interpreter with limited functionality; otherwise the slave
	      will  include  the  full	set of Tcl built-in commands and vari-
	      ables. The -- switch can be used to mark the  end  of  switches;
	      it  may be needed if path is an unusual value such as -safe. The
	      result of the command is the name of the	new  interpreter.  The
	      name  of a slave interpreter must be unique among all the slaves
	      for its master;  an error occurs if a slave interpreter  by  the
	      given name already exists in this master.  The initial recursion
	      limit of the slave interpreter is set to the  current  recursion
	      limit of its parent interpreter.

       interp delete ?path ...?
	      Deletes  zero  or  more  interpreters given by the optional path
	      arguments, and for each interpreter, it also deletes its slaves.
	      The  command also deletes the slave command for each interpreter
	      deleted.	For each path argument, if no interpreter by that name
	      exists, the command raises an error.

       interp eval path arg ?arg ...?
	      This  command  concatenates all of the arg arguments in the same
	      fashion as the concat  command,  then  evaluates	the  resulting
	      string  as  a  Tcl script in the slave interpreter identified by
	      path. The result of this evaluation (including error information
	      such  as	the  errorInfo	and  errorCode	variables, if an error
	      occurs) is returned to the invoking interpreter.	Note that  the
	      script  will  be	executed in the current context stack frame of
	      the path interpreter; this is so that the implementations (in  a
	      master  interpreter)  of aliases in a slave interpreter can exe-
	      cute scripts in the slave that find out  information  about  the
	      slave's current state and stack frame.

       interp exists path
	      Returns	1  if a slave interpreter by the specified path exists
	      in this master, 0 otherwise. If path is  omitted,  the  invoking
	      interpreter is used.

       interp expose path hiddenName ?exposedCmdName?
	      Makes the hidden command hiddenName exposed, eventually bringing
	      it back under a new exposedCmdName name (this name is  currently
	      accepted	only  if  it is a valid global name space name without
	      any ::), in the interpreter denoted by path.  If an exposed com-
	      mand  with the targeted name already exists, this command fails.
	      Hidden commands are explained in more detail in HIDDEN COMMANDS,
	      below.

       interp hide path exposedCmdName ?hiddenCmdName?
	      Makes  the exposed command exposedCmdName hidden, renaming it to
	      the hidden command hiddenCmdName, or keeping the	same  name  if
	      hiddenCmdName  is not given, in the interpreter denoted by path.
	      If a hidden command with the targeted name already exists,  this
	      command  fails.  Currently both exposedCmdName and hiddenCmdName
	      can not contain namespace qualifiers, or	an  error  is  raised.
	      Commands to be hidden by interp hide are looked up in the global
	      namespace even if the current namespace is not the  global  one.
	      This prevents slaves from fooling a master interpreter into hid-
	      ing the wrong command, by making the current namespace  be  dif-
	      ferent  from  the  global one.  Hidden commands are explained in
	      more detail in HIDDEN COMMANDS, below.

       interp hidden path
	      Returns a list of the names of all hidden commands in the inter-
	      preter identified by path.

       interp invokehidden path ?-global? hiddenCmdName ?arg ...?
	      Invokes the hidden command hiddenCmdName with the arguments sup-
	      plied in the interpreter denoted by path.  No  substitutions  or
	      evaluation are applied to the arguments.	If the -global flag is
	      present, the hidden command is invoked at the  global  level  in
	      the  target  interpreter; otherwise it is invoked at the current
	      call frame and can access local variables in that and outer call
	      frames.	Hidden commands are explained in more detail in HIDDEN
	      COMMANDS, below.

       interp issafe ?path?
	      Returns 1 if the interpreter identified by the specified path is
	      safe, 0 otherwise.

       interp marktrusted path
	      Marks  the  interpreter  identified by path as trusted. Does not
	      expose the hidden commands. This command	can  only  be  invoked
	      from  a  trusted	interpreter.  The command has no effect if the
	      interpreter identified by path is already trusted.

       interp recursionlimit path ?newlimit?
	      Returns the maximum allowable nesting depth for the  interpreter
	      specified  by  path.   If newlimit is specified, the interpreter
	      recursion limit will  be	set  so  that  nesting	of  more  than
	      newlimit	calls  to  Tcl_Eval()  and  related procedures in that
	      interpreter will return an error.  The newlimit  value  is  also
	      returned.  The newlimit value must be a positive integer between
	      1 and the maximum value of a non-long integer on the platform.

	      The command sets the maximum size of the Tcl call stack only. It
	      cannot  by  itself  prevent stack overflows on the C stack being
	      used by the application. If your machine has a limit on the size
	      of  the C stack, you may get stack overflows before reaching the
	      limit set by the command. If this happens, see  if  there  is  a
	      mechanism  in your system for increasing the maximum size of the
	      C stack.

       interp share srcPath channelId destPath
	      Causes the IO channel identified by channelId to	become	shared
	      between  the  interpreter  identified  by srcPath and the inter-
	      preter identified by destPath. Both interpreters have  the  same
	      permissions  on the IO channel.  Both interpreters must close it
	      to close the underlying IO channel; IO channels accessible in an
	      interpreter  are	automatically  closed  when  an interpreter is
	      destroyed.

       interp slaves ?path?
	      Returns a Tcl list of the names of all  the  slave  interpreters
	      associated  with	the interpreter identified by path. If path is
	      omitted, the invoking interpreter is used.

       interp target path alias
	      Returns a Tcl list describing  the  target  interpreter  for  an
	      alias.  The  alias  is  specified  with  an interpreter path and
	      source command name, just as in interp alias above. The name  of
	      the target interpreter is returned as an interpreter path, rela-
	      tive to the invoking interpreter.  If the target interpreter for
	      the  alias  is  the  invoking  interpreter then an empty list is
	      returned. If the target interpreter for the  alias  is  not  the
	      invoking	interpreter or one of its descendants then an error is
	      generated.  The target command does not have to  be  defined  at
	      the time of this invocation.

       interp transfer srcPath channelId destPath
	      Causes  the  IO channel identified by channelId to become avail-
	      able in the interpreter identified by destPath  and  unavailable
	      in the interpreter identified by srcPath.

SLAVE COMMAND
       For  each  slave interpreter created with the interp command, a new Tcl
       command is created in the master interpreter with the same name as  the
       new  interpreter. This command may be used to invoke various operations
       on the interpreter.  It has the following general form:	slave  command
       ?arg  arg  ...?	 Slave is the name of the interpreter, and command and
       the args determine the exact behavior of the command.  The valid  forms
       of this command are:

       slave aliases
	      Returns  a  Tcl  list  whose  elements are the tokens of all the
	      aliases in slave.  The tokens correspond to the values  returned
	      when  the aliases were created (which may not be the same as the
	      current names of the commands).

       slave alias srcToken
	      Returns a Tcl list whose elements are  the  targetCmd  and  args
	      associated  with	the alias represented by srcToken (this is the
	      value returned when the alias was created; it is	possible  that
	      the  actual source command in the slave is different from srcTo-
	      ken).

       slave alias srcToken {}
	      Deletes the alias for srcToken in the slave interpreter.	srcTo-
	      ken refers to the value returned when the alias was created;  if
	      the source command has been renamed, the renamed command will be
	      deleted.

       slave alias srcCmd targetCmd ?arg ..?
	      Creates  an alias such that whenever srcCmd is invoked in slave,
	      targetCmd is invoked in the master.  The arg arguments  will  be
	      passed  to  targetCmd  as additional arguments, prepended before
	      any arguments passed in the invocation  of  srcCmd.   See  ALIAS
	      INVOCATION  below for details.  The command returns a token that
	      uniquely identifies the command created srcCmd, even if the com-
	      mand  is	renamed afterwards. The token may but does not have to
	      be equal to srcCmd.

       slave eval arg ?arg ..?
	      This command concatenates all of the arg arguments in  the  same
	      fashion  as  the	concat	command,  then evaluates the resulting
	      string as a Tcl script in slave.	The result of this  evaluation
	      (including error information such as the errorInfo and errorCode
	      variables, if an error  occurs)  is  returned  to  the  invoking
	      interpreter.   Note that the script will be executed in the cur-
	      rent context stack frame of slave; this is so that the implemen-
	      tations  (in  a master interpreter) of aliases in a slave inter-
	      preter can execute scripts in the slave that find  out  informa-
	      tion about the slave's current state and stack frame.

       slave expose hiddenName ?exposedCmdName?
	      This  command  exposes the hidden command hiddenName, eventually
	      bringing it back under a new exposedCmdName name (this  name  is
	      currently  accepted only if it is a valid global name space name
	      without any ::), in slave.  If an exposed command with the  tar-
	      geted name already exists, this command fails.  For more details
	      on hidden commands, see HIDDEN COMMANDS, below.

       slave hide exposedCmdName ?hiddenCmdName?
	      This command hides the exposed command exposedCmdName,  renaming
	      it to the hidden command hiddenCmdName, or keeping the same name
	      if the argument is not given, in the slave  interpreter.	 If  a
	      hidden  command with the targeted name already exists, this com-
	      mand fails.  Currently both exposedCmdName and hiddenCmdName can
	      not  contain  namespace qualifiers, or an error is raised.  Com-
	      mands to be hidden are looked up in the global namespace even if
	      the  current  namespace  is  not	the  global one. This prevents
	      slaves from fooling a master interpreter into hiding  the  wrong
	      command,	by  making the current namespace be different from the
	      global one.  For more details on	hidden	commands,  see	HIDDEN
	      COMMANDS, below.

       slave hidden
	      Returns a list of the names of all hidden commands in slave.

       slave invokehidden ?-global hiddenName ?arg ..?
	      This command invokes the hidden command hiddenName with the sup-
	      plied arguments, in slave. No substitutions or  evaluations  are
	      applied  to  the	arguments.   If the -global flag is given, the
	      command is invoked at the global level in the  slave;  otherwise
	      it  is  invoked  at  the current call frame and can access local
	      variables in that or outer call frames.	For  more  details  on
	      hidden commands, see HIDDEN COMMANDS, below.

       slave issafe
	      Returns  1 if the slave interpreter is safe, 0 otherwise.

       slave marktrusted
	      Marks the slave interpreter as trusted. Can only be invoked by a
	      trusted interpreter. This command does  not  expose  any	hidden
	      commands	in the slave interpreter. The command has no effect if
	      the slave is already trusted.

       slave recursionlimit ?newlimit?
	      Returns the maximum allowable nesting depth for the slave inter-
	      preter.	If newlimit is specified, the recursion limit in slave
	      will be set so that nesting  of  more  than  newlimit  calls  to
	      Tcl_Eval() and related procedures in slave will return an error.
	      The newlimit value is also returned.  The newlimit value must be
	      a positive integer between 1 and the maximum value of a non-long
	      integer on the platform.

	      The command sets the maximum size of the Tcl call stack only. It
	      cannot  by  itself  prevent stack overflows on the C stack being
	      used by the application. If your machine has a limit on the size
	      of  the C stack, you may get stack overflows before reaching the
	      limit set by the command. If this happens, see  if  there  is  a
	      mechanism  in your system for increasing the maximum size of the
	      C stack.

SAFE INTERPRETERS
       A safe interpreter is one with restricted  functionality,  so  that  is
       safe  to execute an arbitrary script from your worst enemy without fear
       of that script damaging the enclosing application or the rest  of  your
       computing  environment.	 In order to make an interpreter safe, certain
       commands and variables are removed from the interpreter.  For  example,
       commands  to  create files on disk are removed, and the exec command is
       removed, since it could be used to cause damage	through  subprocesses.
       Limited access to these facilities can be provided, by creating aliases
       to the master interpreter which check  their  arguments	carefully  and
       provide restricted access to a safe subset of facilities.  For example,
       file creation might be allowed in a particular subdirectory and subpro-
       cess invocation might be allowed for a carefully selected and fixed set
       of programs.

       A safe interpreter is created by specifying the	-safe  switch  to  the
       interp create command.  Furthermore, any slave created by a safe inter-
       preter will also be safe.

       A safe interpreter is created with exactly the following set of	built-
       in	  commands:	    after	append	    array	binary
       break	   case        catch	   clock  close       concat	  con-
       tinue	eof		  error       eval	  expr	      fblocked
       fcopy	   fileevent   flush	   for		      foreach	  for-
       mat	gets	    global  if		incr	    info	interp
       join	   lappend     lindex	   linsert
       list	   llength     lrange	   lreplace
       lsearch	   lsort       namespace   package
       pid	   proc        puts	   read 	      regexp	  reg-
       sub	rename	    return   scan	 seek	     set	 split
       string	   subst       switch	   tell
       time	   trace       unset	   update
       uplevel	   upvar       variable    vwait  while The following commands
       are hidden by  interp  create  when  it	creates  a  safe  interpreter:
       cd	   encoding    exec	   exit 		      fconfig-
       ure  file	glob	    load
       open	   pwd	       socket	   source These commands can be recre-
       ated later as Tcl  procedures  or  aliases,  or	re-exposed  by	interp
       expose.

       The following commands from Tcl's library of support procedures are not
       present		 in	      a 	  safe		  interpreter:
       auto_exec_ok    auto_import     auto_load    auto_load_index auto_qual-
       ify    unknown Note  in	particular  that  safe	interpreters  have  no
       default	unknown  command,  so Tcl's default autoloading facilities are
       not available.  Autoload access to Tcl's  commands  that  are  normally
       autoloaded:			 auto_mkindex	      auto_mkindex_old
       auto_reset	    history	      parray		   pkg_mkIndex
       ::pkg::create	    ::safe::interpAddToAccessPath   ::safe::interpCre-
       ate ::safe::interpConfigure   ::safe::interpDelete ::safe::interpFindI-
       nAccessPath	::safe::interpInit   ::safe::setLogCmd	    tcl_endOf-
       Word	   tcl_findLibrary   tcl_startOfNextWord  tcl_startOfPrevious-
       Word  tcl_wordBreakAfter   tcl_wordBreakBefore  can only be provided by
       explicit definition of an unknown  command  in  the  safe  interpreter.
       This  will  involve  exposing  the source command.  This is most easily
       accomplished by creating the safe interpreter with Tcl's Safe-Tcl mech-
       anism.	Safe-Tcl provides safe versions of source, load, and other Tcl
       commands needed to support autoloading of commands and the  loading  of
       packages.

       In  addition, the env variable is not present in a safe interpreter, so
       it cannot share environment variables with other interpreters. The  env
       variable  poses	a  security  risk,  because  users can store sensitive
       information in an environment variable. For  example,  the  PGP	manual
       recommends storing the PGP private key protection password in the envi-
       ronment variable PGPPASS. Making this variable available  to  untrusted
       code executing in a safe interpreter would incur a security risk.

       If  extensions  are  loaded  into  a  safe  interpreter,  they may also
       restrict their own functionality to eliminate unsafe  commands.	For  a
       discussion  of  management  of  extensions  for	safety	see the manual
       entries for Safe-Tcl and the load Tcl command.

       A safe interpreter may not alter the  recursion	limit  of  any	inter-
       preter, including itself.

ALIAS INVOCATION
       The  alias mechanism has been carefully designed so that it can be used
       safely when an untrusted script is executing in a safe  slave  and  the
       target  of  the alias is a trusted master.  The most important thing in
       guaranteeing safety is to ensure that information passed from the slave
       to the master is never evaluated or substituted in the master;  if this
       were to occur, it would enable an evil script in the  slave  to	invoke
       arbitrary functions in the master, which would compromise security.

       When  the  source for an alias is invoked in the slave interpreter, the
       usual Tcl substitutions are performed when parsing that command.  These
       substitutions  are  carried  out in the source interpreter just as they
       would be for any other command invoked in that interpreter.   The  com-
       mand  procedure	for  the source command takes its arguments and merges
       them with the targetCmd and args for the alias to create a new array of
       arguments.   If the words of srcCmd were ``srcCmd arg1 arg2 ... argN'',
       the new set of words will be ``targetCmd arg arg ... arg arg1 arg2  ...
       argN'', where targetCmd and args are the values supplied when the alias
       was created.  TargetCmd is then used to locate a command  procedure  in
       the  target interpreter, and that command procedure is invoked with the
       new set of arguments.  An error occurs if there	is  no	command  named
       targetCmd  in  the target interpreter.  No additional substitutions are
       performed on the  words:   the  target  command	procedure  is  invoked
       directly,  without  going  through the normal Tcl evaluation mechanism.
       Substitutions are thus performed on each word exactly  once:  targetCmd
       and  args  were	substituted  when parsing the command that created the
       alias, and arg1 - argN are substituted when the alias's source  command
       is parsed in the source interpreter.

       When  writing  the  targetCmds  for aliases in safe interpreters, it is
       very important that the arguments to that command never be evaluated or
       substituted,  since  this would provide an escape mechanism whereby the
       slave interpreter could execute arbitrary code in the master.  This  in
       turn would compromise the security of the system.

HIDDEN COMMANDS
       Safe  interpreters  greatly restrict the functionality available to Tcl
       programs executing within them.	Allowing the untrusted Tcl program  to
       have  direct  access to this functionality is unsafe, because it can be
       used for a variety of attacks on the environment.  However,  there  are
       times  when there is a legitimate need to use the dangerous functional-
       ity in the context of the safe interpreter. For	example,  sometimes  a
       program	must  be sourced into the interpreter.	Another example is Tk,
       where windows are bound to the hierarchy  of  windows  for  a  specific
       interpreter; some potentially dangerous functions, e.g.	window manage-
       ment, must be performed on these windows within	the  interpreter  con-
       text.

       The  interp  command provides a solution to this problem in the form of
       hidden commands. Instead of removing the  dangerous  commands  entirely
       from  a	safe  interpreter,  these  commands  are hidden so they become
       unavailable to Tcl scripts executing in the interpreter. However,  such
       hidden  commands  can  be  invoked  by any trusted ancestor of the safe
       interpreter, in the context  of	the  safe  interpreter,  using	interp
       invoke.	Hidden	commands  and exposed commands reside in separate name
       spaces. It is possible to define a hidden command and an  exposed  com-
       mand by the same name within one interpreter.

       Hidden  commands  in  a slave interpreter can be invoked in the body of
       procedures called in the master during alias invocation.  For  example,
       an alias for source could be created in a slave interpreter. When it is
       invoked in the slave interpreter, a procedure is called in  the	master
       interpreter  to	check that the operation is allowable (e.g. it asks to
       source a file that the slave interpreter is  allowed  to  access).  The
       procedure then it invokes the hidden source command in the slave inter-
       preter to actually source in the contents of the file.  Note  that  two
       commands  named	source	exist in the slave interpreter: the alias, and
       the hidden command.

       Because a master interpreter may invoke a hidden  command  as  part  of
       handling  an alias invocation, great care must be taken to avoid evalu-
       ating any arguments passed in through the alias invocation.  Otherwise,
       malicious  slave  interpreters could cause a trusted master interpreter
       to execute dangerous commands on their behalf. See the section on ALIAS
       INVOCATION for a more complete discussion of this topic.  To help avoid
       this problem, no substitutions or evaluations are applied to  arguments
       of interp invokehidden.

       Safe  interpreters  are	not allowed to invoke hidden commands in them-
       selves or in their descendants. This prevents safe slaves from  gaining
       access to hidden functionality in themselves or their descendants.

       The  set  of  hidden commands in an interpreter can be manipulated by a
       trusted interpreter using interp expose and  interp  hide.  The	interp
       expose command moves a hidden command to the set of exposed commands in
       the interpreter identified by path, potentially renaming the command in
       the process. If an exposed command by the targeted name already exists,
       the operation fails. Similarly, interp hide moves an exposed command to
       the  set  of hidden commands in that interpreter. Safe interpreters are
       not allowed to move commands between the set of hidden and exposed com-
       mands, in either themselves or their descendants.

       Currently, the names of hidden commands cannot contain namespace quali-
       fiers, and you must first rename a command in a namespace to the global
       namespace before you can hide it.  Commands to be hidden by interp hide
       are looked up in the global namespace even if the current namespace  is
       not  the  global one. This prevents slaves from fooling a master inter-
       preter into hiding the wrong command, by making the  current  namespace
       be different from the global one.

CREDITS
       This  mechanism	is  based  on  the  Safe-Tcl  prototype implemented by
       Nathaniel Borenstein and Marshall Rose.

EXAMPLES
       Creating and using an alias for a command in the  current  interpreter:
       interp  alias  {}  getIndex {} lsearch {alpha beta gamma delta} set idx
       [getIndex delta]

       Executing an arbitrary  command	in  a  safe  interpreter  where  every
       invokation  of  lappend	is  logged: set i [interp create -safe] interp
       hide $i lappend interp  alias  $i  lappend  {}  loggedLappend  $i  proc
       loggedLappend {i args} {
	  puts "logged invokation of lappend $args"
	  # Be extremely careful about command construction
	  eval [linsert $args 0 \
		interp invokehidden $i lappend] } interp eval $i $someUntrust-
       edScript


SEE ALSO
       load(n), safe(n), Tcl_CreateSlave(3)


KEYWORDS
       alias, master interpreter, safe interpreter, slave interpreter



Tcl				      7.6			     interp(n)
=1963
+136
(102)