What-dir 将自己的目录报告为 Rebol 中的当前目录

What-dir reporting own directory as current directory in Rebol

我正在 运行在 Debian 稳定版 Linux 上使用 Rebol,我已将 rebol 可执行文件放入 /usr/local/bin。然后我创建了以下脚本文件并将其保存在 /usr/local/bin:

#! /usr/local/bin/rebol

REBOL []

print what-dir
quit

然而,当我从任何目录 运行 这个脚本时,它只报告“/usr/local/bin/”而不是当前工作目录。我想获取当前工作目录以从代码执行操作。

以下代码,使用 Linux shell 命令 pwd(打印工作目录)也报告相同的内容:

print call "pwd"

如何解决这个问题?

您可以在 system/options/path 中找到您的 自己的目录,如果您希望它成为您的 current working directory and what-dir 报告你自己的目录为当前目录,你必须添加这一行

system/script/path: system/options/path

change-dir system/options/path

在调用 what-dir 之前。

甚至 call "pwd" 现在也使用并显示您自己的目录作为 Linux

下的当前目录

我同意,这种行为很不直观。

我前一段时间遇到过同样的情况,我一遍又一遍地犯同样的错误......我最终把那个 change-dir system/options/path 放在一个更通用的例程脚本中,它是从我的~/.rebol/view/user.r.

不过请注意,也可以将该语句放在 user.r.