What-dir reporting own directory as current direct

2019-07-28 11:12发布

问题:

I am running Rebol on Debian Stable Linux and I have put rebol executable in /usr/local/bin. Then I have created following script file and also kept it in /usr/local/bin:

#! /usr/local/bin/rebol

REBOL []

print what-dir
quit

However, when I run this script from any directory, it only reports "/usr/local/bin/" and not current working directory. I want to get current working directory to perform operations from code.

Following code, using Linux shell command pwd (print working directory) also reports the same:

print call "pwd"

How can this problem be solved?

回答1:

You can find your own directory where you are in system/options/path and if you want it to be your current working directory and what-dir to report your own directory as current directory, you have to add this line

system/script/path: system/options/path

or

change-dir system/options/path

before calling what-dir.

Even call "pwd" uses and shows now your own as current directory under Linux



回答2:

I agree, this behaviour is quite unintuitive.

I came across the same situation a while ago, and I kept on making the same mistake over and over... I eventually placed that change-dir system/options/path in a more general routines script, which is loaded from my ~/.rebol/view/user.r.

Mind you though, one could also put that statement within the user.r.



标签: linux rebol