1

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?

rnso
  • 23,686
  • 25
  • 112
  • 234
  • CALL automatically prints any output and returns the shell return code (`0` for success). If you want to capture output from CALL, you'll need to use CALL/OUTPUT: `trim/tail also out: make string! 60 call/output "pwd" out` – rgchris Oct 02 '17 at 01:28

2 Answers2

2

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

sqlab
  • 6,412
  • 1
  • 14
  • 29
0

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.

Pierre
  • 530
  • 5
  • 13