safe

safe(3tcl)                   Tcl Built-In Commands                  safe(3tcl)



NAME
       Safe - ç¨æ¥å»ºç«åæ纵å®å¨è§£éå¨çæºå¶ã

æ»è§ SYNOPSIS
       ::safe::interpCreate ?slave? ?options...?

       ::safe::interpInit slave ?options...?

       ::safe::interpConfigure slave ?options...?

       ::safe::interpDelete slave

       ::safe::interpAddToAccessPath slave directory

       ::safe::interpFindInAccessPath slave directory

       ::safe::setLogCmd ?cmd arg...?

OPTIONS
       ?-accessPath pathList?  ?-statics boolean? ?-noStatics?  ?-nested
       boolean? ?-nestedLoadOk?  ?-deleteHook script?


æè¿° DESCRIPTION
       Safe Tcl æ¯ä¸ç§æºå¶ï¼ç¨äºå®å¨çæ§è¡ä¸å¯ä¿¡ä»»ç Tcl
       èæ¬ï¼å¹¶ä¸ºææ½å¨å±é©åè½çèæ¬æä¾è®¿é®ä¸ä»ã

       Safe Base ç¡®ä¿ä¸å¯ä¿¡ä»»ç Tcl èæ¬ä¸è½æå宿主åºç¨ãSafe Base é²æ‐
       ¢å®æ´æ§åéç§æ»å»ãé²æ¢ä¸å¯ä¿¡ä»»ç Tcl èæ¬è´¥å宿主åºç¨æ计ç®æºçç¶åµãé²æ‐
       ¢ä¸å¯ä¿¡ä»»çèæ¬æåå¨å¨å®¿ä¸»ä¸»æºæ宿主åºç¨ä¸çä¿¡æ¯æ³é²ç»ä»»ä½äººç¾¤ã

       Safe Base å许ä¸ä¸ªä¸»è§£éå¨å»ºç«å®å¨ãåéå¶ç解éå¨ï¼å®åæ¬ä¸º  source,
       load, file, encoding, å exit
       å½ä»¤é¢å®ä¹çä¸ç³»åå«åï¼å¹¶å¯ä»¥ä½¿ç¨èªå¨è£è½½ååæºå¶ã

       ä¸åå®å¨è§£éå¨éé²æ件系ç»çä»»ä½ä¸è¥¿ï¼å®åªè½è®¿é®åå«è®°å·(token)çèæçè·¯å¾ãå½å®å¨è§£éå¨è¯·æ±
       source(è½½å¥)ä¸ä¸ªæ件çæ¶åï¼å®ä½¿ç¨å¨èæè·¯å¾ä¸çè®°å·ä½ä¸ºè¦ source
       çæ件åçä¸é¨åï¼ä¸»è§£éå¨éæçæè¿ä¸ªè®°å·è½¬æ¢æä¸ä¸ªå®éçè·¯å¾å并æ§è¡æè¦æ±çæä½
       (详æåè§ä¸é¢ç SECURITY å®å¨ ç« è).
       å¯ä»¥ä½¿ç¨ä¸é¢æè¿°çå½ä»¤æ å¿æ¥éæ©ä¸åçå®å¨çº§å«ã

       Safe Base å¨ä¸»è§£éå¨ä¸æä¾çææå½ä»¤é©»çå¨ safe åå空é´ä¸:


å½ä»¤ COMMANDS
       å¨ä¸»è§£éå¨ä¸æä¾äºä¸åå½ä»¤:

       ::safe::interpCreate ?slave? ?options...?
              建ç«ä¸ä¸ªå®å¨è§£éå¨ï¼å®è£å¨ALIASES  å«å ç« èä¸æè¿°çå«å并åå§åå¨
              OPTIONS é项 ä¸æä¾çèªå¨è£è½½ååæºå¶ã对å¯éæ©çåæ°çæ述请åè§ä¸é¢
              OPTIONS é项 ç« èãå¦æçç¥äºslave åæ°ï¼åçæä¸ä¸ªåå‐
              ã::safe::interpCreate æ»æ¯è¿å解éå¨çååã

       ::safe::interpInit slave ?options...?
              é¤äºä¸å»ºç«å®å¨è§£éå¨ä¹å¤ï¼è¿ä¸ªå½ä»¤ç±»ä¼¼äº interpCreate
              å½ä»¤ãå¿é¡»å·²ç»éè¿å¶ä»æ¹å¼å¦ interp create -safe建ç«äºè¿ä¸ª
              slaveã

       å¦ææªç»åº optionsï¼åæç»æåçè¿ä¸ªè§£éå¨ææé项ç设置è¿å为ç»è¿ä¸ª slave
       çé项åå®ä»¬å½åçå¼çä¸ä¸ªå表ãå¦ææä¾äºä¸ä¸ªåä¸çè¡¥ååæ°ï¼å®å°è¿åæ两个åç´
       name å value çä¸ä¸ªå表ï¼è¿éç name æ¯é项çå¨åè value æ¯ç» slave
       çè¿ä¸ªé项å½åå¼ãå¦ææä¾å¤äºä¸¤ä¸ªè¡¥åé项ï¼å®å°éæ°éç½®è¿ä¸ªå®å¨è§£éå¨å¹¶åªæ¹åæ¯ä¸ªæä¾çé项ãå³äºé项çæ述请åè§ä¸é¢ç
       OPTIONS ç« èã使ç¨çä¾å:
              # Create a new interp with the same configuration as "$i0" : set
              i1 [eval safe::interpCreate [safe::interpConfigure $i0]] # Get
              the current deleteHook set dh [safe::interpConfigure $i0  -del]
              # Change (only) the statics loading ok attribute of an interp #
              and its deleteHook (leaving the rest unchanged) :
              safe::interpConfigure $i0  -delete {foo bar} -statics 0 ;

       ::safe::interpDelete slave
              å é¤è¿ä¸ªå®å¨è§£éå¨å¹¶æ¸é¤ç¸åºç主解éå¨æ°æ®ç»æãå¦æ为è¿ä¸ªè§£éå¨æå®äºä¸ä¸ª
              deleteHook
              èæ¬ï¼åå¨å é¤è¿ä¸ªè§£éå¨ä¹åæ§è¡è¿ä¸ªèæ¬ï¼æè¿ä¸ªè§£éå¨çåå‐
              ä½ä¸ºä¸ä¸ªè¡¥ååæ°ã

       ::safe::interpFindInAccessPath slave directory
              è¿ä¸ªå½ä»¤å¯»æ¾å¹¶è¿åå¨å®å¨è§£éå¨çå½åèæ访é®è·¯å¾ä¸ç»å®éè·¯å¾
              directory çè®°å·ãå¦ææªæ¾å°è¿ä¸ªè·¯å¾åçæä¸ä¸ªé误ã使ç¨çä¾å:
              $slave eval [list set tk_library [::safe::interpFindInAccessPath
              $name $tk_library]]

       ::safe::interpAddToAccessPath slave directory
              è¿ä¸ªå½ä»¤æ directory æ·»å å°å¨ä¸»è§£éå¨ä¸‐
              为å®å¨è§£éå¨ç»´æ¤çèæè·¯å¾ä¸ï¼å¹¶è¿åå¯å¨å®å¨è§£éå¨ä¸‐
              被ç¨æ¥è·å¾å°å¨è¿ä¸ªç®å½ä¸çæ件ç访é®çè®°å·ãå¦æè¿ä¸ªè·¯å¾å·²ç»å‐
              å¨äºèæè·¯å¾ä¸ï¼åå®åªè¿åè®°å·èä¸å次æè¿ä¸ªè·¯å¾æ·»å å°èæè·¯å¾ä¸‐
              ã使ç¨çä¾å:
              $slave eval [list set tk_library [::safe::interpAddToAccessPath
              $name $tk_library]]

       ::safe::setLogCmd ?cmd arg...?
              è¿ä¸ªå½ä»¤å®è£å¨ä¸ä¸ªèæ¬ï¼å¨è¿ä¸ªå®å¨è§£éå¨çç¹å®ççå½å¨æäºä»¶åççæ¶åå°è¢«è°ç¨ãå¨è°ç¨è¿ä¸ªå½ä»¤èä¸å åæ°æ¶ï¼å®è¿åå½åå®è£çèæ¬ãå¨è°ç¨å¹¶å ä¸ä¸ªåæ°ç©ºä¸²æ¶ï¼åå é¤å½åå®è£çèæ¬å¹¶å³é‐
              æ¥å¿è®°å½ãè°ç¨è¿ä¸ªèæ¬æ¶å°å ä¸ä¸ä¸ªè¡¥ååæ°ï¼å®æè¿°ææå´è¶£çäºä»¶ã主è¦çç®çæ¯å¸®å©è°è¯å®å¨è§£éå¨ãå¨å®å¨è§£éå¨åªè½å¾å°ä¸ä¸ªä¸è¬é误æ¶æ¯çæ¶åä½ å¯ä»¥ä½¿ç¨è¿ä¸ªè®¾æ½è·å¾å®æ´çé误æ¶æ¯ãè¿é²æ‐
              ¢å®å¨è§£éå¨è§å°å³äºå¤±è´¥çæ¶æ¯åå¶ä»å¯è½åå«ææä¿¡æ¯å¦çå®è·¯å¾åçå¶ä»äºä»¶çæ¶æ¯ã
              使ç¨çä¾å:

              ::safe::setLogCmd puts stderr

              ä¸é¢æ¯ä¸ä¸ªæ ·æ¬å¯¹è¯çè¾åºï¼è¿éä¸ä¸ªå®å¨è§£éå¨å°è¯ç source
              ä¸ä¸ªå¨å®çèæ 访é®è·¯å¾ä¸‐
              æ¾ä¸å°çæ件ã注æè¿ä¸ªå®å¨è§£éå¨åªæ¥æ¶å°ä¸ä¸ªé误æ¶æ¯ï¼è¯´è¿ä¸ªæ
              件æªæ¾å°:

              NOTICE for slave interp10 : Created
              NOTICE for slave interp10 : Setting accessPath=(/foo/bar) staticsok=1 nestedok=0 deletehook=()
              NOTICE for slave interp10 : auto_path in interp10 has been set to {$p(:0:)}
              ERROR for slave interp10 : /foo/bar/init.tcl: no such file or directory


é项 OPTIONS
       ä¸åé项éç¨äº ::safe::interpCreateã::safe::interpInitãå
       ::safe::interpConfigureãä»»ä½é项é½å¯ç¼©å为å®çæå°çæ æ§ä¹çååãé项çåå‐
       æ¯å¤§å°åä¸ææçã

       -accessPath directoryList
              è¿ä¸ªé项设置ç®å½çå表ï¼å®å¨è§£éå¨å¯ä»¥ä»ä¸ source å load
              æ件ãå¦ææªæå®è¿ä¸ªé项ï¼æèå®è¢«ç»å®ä¸ºä¸ä¸ªç©ºå表ï¼å®å¨è§£éå¨å°ä½¿ç¨çç®å½åä¸å®ç主解éå¨ç¨äºèªå¨è£è½½çç®å½ãå³äºèæè·¯å¾ãè®°å·å访é®æ§å¶ç详æ请åè§ä¸é¢ç
              SECURITY å®å¨ ç« èã

       -statics boolean
              è¿ä¸ªé项æå®æ¯å¦å许è¿ä¸ªå®å¨è§£éå¨è£è½½éæè¿æ¥å(å¦ load {}
              Tk)ã缺çå¼æ¯ true : å许å®å¨è§£éå¨è£è½½éæè¿æ¥åã

       -noStatics
              è¿ä¸ªéé¡¹æ¯ -statics false
              çä¸ä¸ªæ¹ä¾¿çç®åï¼å®æå®ä¸å许è¿ä¸ªå®å¨è§£éå¨è£è½½éæè¿æ¥åã

       -nested boolean
              è¿ä¸ªé项æå®æ¯å¦å许è¿ä¸ªå®å¨è§£éå¨æåè£è½½å°å®èªå·±çå解éå¨ä¸‐
              ã缺çå¼æ¯     false :     ä¸å许å®å¨è§£éå¨æåè£è½½å°å®èªå·±çå‐
              解éå¨ä¸ã

       -nestedLoadOk
              è¿ä¸ªéé¡¹æ¯ -nested true
              çä¸ä¸ªæ¹ä¾¿çç®åï¼å®æå®å许å®å¨è§£éå¨æåè£è½½å°å®èªå·±çå解éå¨ä¸ã

       -deleteHook script
              å½ç»è¿ä¸ªé项以ä¸ä¸ªé空ç script
              çæ¶åï¼å®å°å¨å®éå é¤è¿ä¸ªä»è§£éå¨ä¹åå¨ä¸»è§£éå¨ä¸‐
              被æ±å¼ï¼å¹¶å ä¸è¿ä¸ªå®å¨è§£éå¨çåå‐
              ä½ä¸ºä¸ä¸ªè¡¥åçåæ°ãç»äºä¸ä¸ªç©ºå¼åå»é¤ä»»ä½å½å为è¿ä¸ªå®å¨è§£éå¨å®è£çå é¤åè°(hook)èæ¬ã缺çå¼({})æ¯æ²¡æä»»ä½å é¤åè°èæ¬ã

å«å ALIASES
       å¨å®å¨è§£éå¨ä¸æä¾äºä¸åå«å:

       source fileName
              å¦ææ¾å°äºè¦æ±çè¿ä¸ª Tcl æºæ件ï¼åæå®
              source(è£è½½)å°å®å¨è§£éå¨ä¸ã source
              å«ååªå¯ä»¥ä»ç»è¿ä¸ªå®å¨è§£éå¨çèæè·¯å¾ä¸çç®å½ source æ件ã
              å³äºå¨æææ件åä¸çéå¶çæ´å¤ä¿¡æ¯è¯·åè§ SECURITY å®å¨ ç« èã

       load fileName
              å¦ææ¾å°äºè¦æ±çè¿ä¸ªå±äº«çç®æ æ件ï¼åæå®å¨æçè£è½½å°å®å¨è§£éå¨ä¸‐
              ã为äºè½æåçæ¾å°å®ï¼æ件åå¿é¡»åå«å¨ç»è¿ä¸ªå®å¨è§£éå¨çèæè·¯å¾ä¸‐
              æåçä¸ä¸ªè®°å·çåå‐
              ãè¿æï¼è¿ä¸ªå±äº«çç®æ æ件å¿é¡»åå«ä¸ä¸ªå®å¨å¥å£ç¹ï¼è¯¦æ请åè§
              load å½ä»¤çæåæ¡ç®ã

       file ?subCmd args...?
              file å«åæä¾å° fileå½ä»¤çåå½ä»¤çä¸ä¸ªå®å¨åéç访é®ï¼å®åªå许
              dirnameãjoinã  extensionãrootãtailãpathname å split  å‐
              å½ä»¤ãå³äºè¿äºåå½ä»¤ç详æ请åè§ file  å½ä»¤çæåæ¡ç®ã

       encoding ?subCmd args...?
              enconding å«åæä¾å° encoding å½ä»¤çåå½ä»¤çä¸ä¸ªå®å¨å‐
              éç访é®ï¼å®ä¸å许设置系ç»ç¼ç ï¼ä¸å许å¶ä»åå½ä»¤åæ¬ system
              æ£æ¥å½åç¼ç ã

       exit   å é¤è°ç¨å®çèæ¬å¹¶åæ¢å®ç计ç®ï¼ä½è¿ä¸ªè§£éå¨åå¨äºå¶ä¸çé£ä¸ª Tcl
              è¿ç¨ä¸è¢«ç»æ¢ã


å®å¨ SECURITY
       Safe Base ä¸å°è¯å®å¨çé²æ‐
       ¢ç¦æ¼(annoyance)åæç»æå¡æ»å»ãè¿äºå½¢å¼çæ»å»å¦¨ç¢åºç¨æç¨æ·ä¸´æ¶ç使ç¨è®¡ç®æºæ¥å®ææç¨çå·¥ä½ï¼ä¾å¦æ¶èææå¯å©ç¨ç
       CPU æ¶é´æææå¯å©ç¨çå±å¹ real estateãè¿äºæ»å»å°½ç®¡å¾æ¶å£ï¼ä½ä¸è¬ä¸å¦
       Safe Base 主è¦é²æ¤çå®æ´æ§åéç§æ»å»é£ä¹éè¦ã

       é¤äºå¨ interp æå页ä¸å®ä¹çå®å¨å½ä»¤éä¹å¤ï¼å¨å®å¨è§£éå¨ä¸‐
       å¯è·å¾çå½ä»¤è¿åæ¬ç» sourceãloadãexit çä½ä¸ºä¸ä»ç(mediate)å«å以å file å
       encoding å½ä»¤çå®å¨å‐
       éãå®å¨è§£éå¨è¿å¯ä»¥èªå¨è£è½½ä»£ç 并å¯ä»¥è¯·æ±è£è½½åã

       å 为è¿äºå½ä»¤ä¸çä¸äºå½ä»¤è®¿é®æ¬å°æ件系ç»ï¼å‐
       å¨ç对å®çç®å½ç»æçæ½å¨çä¿¡æ¯æ³é²ã为äºé²æ‐
       ¢è¿ä¸ªé®é¢ï¼æ¥åæ件åä½ä¸ºåæ°çå½ä»¤å¨å®å¨è§£éå¨ä¸‐
       使ç¨è®°å·æ¥æ¿ä»£çå®çç®å½åãå¨ä¸»è§£éå¨ä¸ä»ä¸ä¸ªè¦æ±ä¾å¦ source
       ä¸ä¸ªæ件çæ¶åï¼æè¿äºè®°å·è½¬æ¢æå®éè·¯å¾åãå¨ä¸»è§£éå¨ä¸‐
       ç»´æ¤è¿ä¸ªèæè·¯å¾ç³»ç»ï¼é对æ¯ä¸ªç¨ ::safe::interpCreate 建ç«çæç¨
       ::safe::interpInit åå§åçå®å¨è§£éå¨ï¼è¿ä¸ªè·¯å¾æå¨å®å¨è§£éå¨ä¸‐
       å¯è®¿é®çè®°å·æ å°æå¨æ¬å°æ件系ç»ä¸ççå®è·¯å¾åï¼è¿æ ·å°±é²æ‐
       ¢äºå®å¨è§£éå¨å»è·åå³äºè¿ä¸ªè§£éå¨å¨å¶ä¸æ§è¡ç主æºçæ件系ç»ç»æçç¥è¯ãå¯ä»¥æä¾ç»ä»è§£éå¨ä¸‐
       ç source å load å«åçææçæ件ååæ°åªè½æ¯ä¸é¢è¿ç§å½¢å¼çè·¯å¾ï¼ [file join
       token filename] (æ¯å¦ï¼å¨ä½¿ç¨æ¬å°æ件路å¾æ ¼å¼çæ¶å: å¨ Unix ä¸æ¯
       token/filenameï¼å¨ Windows ä¸æ¯ token\filenameï¼å¨ Mac ä¸æ¯
       token:filename  )ï¼è¿éç token 表示 accessPath å表ä¸çä¸ä¸ªç®å½è
       filename æ¯å¨è¿ä¸ªç®å½ä¸ä¸ä¸ªæ件(ä¸å许访é®åç®å½)ã

       å¨ä¸ä¸ªå®å¨è§£éå¨ä¸ï¼å½å¨è¦ source æè£è½½ä¸ä¸ªæ件çä¸ä¸ªè¯·æ±ä¸‐
       使ç¨ä¸ä¸ªè®°å·çæ¶åï¼æ£æ¥è¿ä¸ªè®°å·å¹¶æå®è½¬æ¢æçå®è·¯å¾åï¼å¹¶å¨æ件系ç»ä¸å®ä½è¦è¢«
       source æè£è½½çæ件ãå®å¨è§£éå¨ä¸è½è·åå³äºæ件系ç»ä¸å¨å¶ä¸å‐
       å¨è¿ä¸ªæ件çå®éè·¯å¾åçç¥è¯ã

       为äºè¿ä¸æ¥é²æ¢æ½å¨ç对å¶ç¶çåæ¬å¨å¯ä»¥è¢«å®å¨è§£éå¨ source çæ件éä¸çæ
       ææ件çä¿¡æ¯æ³é²ï¼éå¶ source å«å为访é®æ»¡è¶³ä¸å约æçæ件: æ件å
       å¿é¡»æ¯åå个å符ææ´çï¼å¿é¡»ä¸åå«å¤äºä¸ä¸ªçç¹(“.”)ï¼ä¸è®¸ç»æ¢äºæ© å±
       .tcl ææ¯è¢«è°ç¨ç tclIndexã

       åå§ç访é®è·¯å¾å表ä¸‐
       çæ¯ä¸ªåç´ å°åéä¸ä¸ªè®°å·ï¼å®ä»¬å°è¢«è®¾ç½®å¨ä»è§£éå¨ç auto_path ä¸‐
       并ä¸è¿ä¸ªå表ç第ä¸ä¸ªåç´ å°è¢«è®¾ç½®ä¸ºè¿ä¸ªä»è§£éå¨ç tcl_libraryã

       å¦ææªç»åºè®¿é®è·¯å¾åæ°æèæ¯ä¸ä¸ªç©ºå表ï¼ç¼ºççè¡ä¸ºæ¯è®©ä»è§£éå¨è®¿é®çåä¸ä¸»è§£éå¨å·²ç»è®¿é®äºçåç¸å(æ´ç²¾ç¡®çæè¿°:
       åªåè®¸ç¨ Tcl åæçå(å 为å®ä»¬å°å¨ä»è§£éå¨ä¸è¿è¡æ以ä¸å¯è½æ¯å±é©ç)åæä¾
       Safe_Init å¥å£ç¹ç C æ©å±)ã为æ¤ï¼ç¨ä¸»è§£éå¨ç auto_path
       æ¥æé ä»è§£éå¨ç访é®è·¯å¾ã为äºä»è§£éå¨è½æåçè£è½½ Tcl
       åºæ件(å®èªèº«åæ¬èªå¨è£è½½æºå¶)ï¼å¦æéè¦çè¯ï¼æ tcl_library
       å¢å æ移å¨å°å¨ä»è§£éå¨ç访é®è·¯å¾ä¸ç第ä¸ä¸ªçä½ç½®ä¸ï¼è¿æ ·ä»è§£éå¨ç
       tcl_library
       å°ä¸ä¸»è§£éå¨çç¸å(å®ççå®è·¯å¾å¯¹ä»è§£éå¨ä»æ¯ä¸å¯è§ç)ã为äºä½¿èªå¨è£è½½å¯¹äºä»è§£éå¨å主解éå¨å¨ç¼ºççæåµä¸ä»¥ç¸åçæ¹å¼å·¥ä½ï¼å¨ä¸»è§£éå¨
       auto_path ä¸çæ¯ä¸ªç®å½ç第ä¸å±å‐
       ç®å½å°è¢«æ·»å (å¦ææªæ¾åå«çè¯)å°ä»è§£éå¨ç访é®è·¯å¾ä¸‐
       ãä½ æ»æ¯å¯ä»¥éè¿æ¾å¼çä½¿ç¨ -accessPath
       æ å¿æå®ä½ çç®å½å表ï¼èä¸æ¯ä¾èµäºè¿ä¸ªç¼ºçæºå¶ï¼æ¥æå®ä¸ä¸ªæ´åéå¶çè·¯å¾ï¼å®çå‐
       ç®å½æ°¸è¿ä¸è½è¢«æ¥æ¾ã

       å¨é¦æ¬¡å»ºç«æåå§å(ä¾å¦éè¿ interpConfigure -accessPath list)ä¹ååæ´
       accessPath çæ¶åï¼å°å¨å®å¨è§£éå¨ä¸èªå¨çæ±å¼ auto_reset æ¥ä½¿å®ç
       auto_index ä¸æ°çè®°å·å表åæ¥ã


åè§ SEE ALSO
       interp(n), library(n), load(n), package(n), source(n), unknown(n)


å³é®å KEYWORDS
       alias, auto-loading, auto_mkindex, load, master interpreter, safe
       interpreter, slave interpreter, source


[ä¸æçç»´æ¤äºº]
       å¯èé士

[ä¸æçææ°æ´æ°]
       2001/11/07

ãä¸å½ Linux 论å man æå页翻è¯è®¡åã:
       http://cmpp.linuxforum.net

è·
       æ¬é¡µé¢ä¸æçç±ä¸æ man æå页计åæä¾ã
       ä¸æ man æå页计åï¼https://github.com/man-pages-zh/manpages-zh



Tcl                                   8.0                           safe(3tcl)