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)