From 91a329eeb75519795137b48fa1d3df64a82db980 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 27 Nov 2021 16:23:41 -0500 Subject: =?UTF-8?q?Specify=20and=20support=20=E2=80=A2wdpath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bqn.js | 1 + docs/spec/system.html | 5 +++++ spec/system.md | 3 +++ 3 files changed, 9 insertions(+) diff --git a/bqn.js b/bqn.js index d4ce27d2..aa584708 100755 --- a/bqn.js +++ b/bqn.js @@ -121,6 +121,7 @@ sysvals.path=dynsys(s=>s.path); sysvals.name=dynsys(s=>s.name); sysvals.args=dynsys(s=>s.args); sysvals.state=dynsys(s=>s.state); +sysvals.wdpath=dynsys(_=>str(dir(path.resolve('.')))); bqn.setexec(update_state, push_state); let bqn_file = (st,f,t,w) => bqn_state(st)( t, [ str(dir(path.dirname(f))), str(path.basename(f)), w ] diff --git a/docs/spec/system.html b/docs/spec/system.html index 41b98728..1fad9ee3 100644 --- a/docs/spec/system.html +++ b/docs/spec/system.html @@ -90,6 +90,10 @@ Current filename +•wdpath +Shell's working directory path + + •Exit Leave the top-level running program @@ -100,6 +104,7 @@

•args is the arguments passed as the file was invoked, either from the command line or •Import. For command line calls it is a list of strings.

•path simply gives the path of the file in which it appears. It includes a trailing slash but not the name of the file itself.

•name gives the name, including the extension, of the file in which it appears. It doesn't include the path.

+

•wdpath returns the path of the current working directory, like the Unix pwd command, but including a trailing slash.

•Exit immediately terminates the running BQN process. If the argument is a valid return code (on Unix, an integer), it is returned; otherwise, the default return code (the one returned when the end of the program is reached) is used.

Files

The system namespace value •file deals with file operations. For the purposes of •file, paths in the filesystem are always strings. As with •Import, file paths may be relative or absolute, and relative paths are relative to •path, except in •file.At which allows 𝕨 to specify an alternate base directory. The value •path used for a particular instance of •file is determined by the file that contains that instance.

diff --git a/spec/system.md b/spec/system.md index b7c66ce9..872126c3 100644 --- a/spec/system.md +++ b/spec/system.md @@ -38,6 +38,7 @@ The option `repl` indicates how variables are retained across calls: with "none" | `•args` | Arguments passed to current file | `•path` | Current file's path | `•name` | Current filename +| `•wdpath` | Shell's working directory path | `•Exit` | Leave the top-level running program `•Import` loads another BQN script. The script is evaluated in its own isolated scope, and its result is either the result of the last line, or a module if it exports with `⇐` at the top level. If it is a module, then it must be destructured immediately unless first-class namespaces are possible. @@ -50,6 +51,8 @@ The right argument is a filename, which may be relative or absolute. Relative pa `•name` gives the name, including the extension, of the file in which it appears. It doesn't include the path. +`•wdpath` returns the path of the current working directory, like the Unix `pwd` command, but including a trailing slash. + `•Exit` immediately terminates the running BQN process. If the argument is a valid return code (on Unix, an integer), it is returned; otherwise, the default return code (the one returned when the end of the program is reached) is used. ## Files -- cgit v1.2.3