跳轉到內容

Rebol 程式設計/cd

來自華夏公益教科書
CD 'path 

更改目錄(shell 快捷函式)。

CD 是一個函式值。

  • path -- 接受 %file、:variables 和普通單詞(作為目錄)(型別:檔案單詞路徑未設定字串括號)

(特殊屬性)

[編輯 | 編輯原始碼]
  • catch

原始碼

[編輯 | 編輯原始碼]
cd: func [
    "Change directory (shell shortcut function)." 
    [catch] 
    'path [file! word! path! unset! string! paren!] "Accepts %file, :variables and just words (as dirs)"
][
    if paren? get/any 'path [set/any 'path do path] 
    switch/default type?/word get/any 'path [
        unset! [print what-dir] 
        file! [change-dir path] 
        string! [change-dir to-rebol-file path] 
        word! path! [change-dir to-file path]
    ] [throw-error 'script 'expect-arg reduce ['cd 'path type? get/any 'path]]
]
華夏公益教科書