Skip to content

Commit

Permalink
Added documentation about '!' in REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
egallesio committed Aug 22, 2024
1 parent 307d56c commit 1307c63
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 54 deletions.
25 changes: 16 additions & 9 deletions doc/HTML/stklos-ref.html
Original file line number Diff line number Diff line change
Expand Up @@ -25649,18 +25649,9 @@ <h4 id="_repl_commands">10.3.1. REPL commands</h4>
<p><strong>,cd</strong>: Change current directory</p>
</li>
<li>
<p><strong>,pwd</strong>: Print working directory</p>
</li>
<li>
<p><strong>,ls</strong>: List directory content</p>
</li>
<li>
<p><strong>,quit</strong> (or <strong>,q</strong>): Exit STklos</p>
</li>
<li>
<p><strong>,shell</strong> (or <strong>,!</strong>): Run a shell command</p>
</li>
<li>
<p><strong>,time</strong> (or <strong>,t</strong> ): Print the time used to run the next expression</p>
</li>
<li>
Expand Down Expand Up @@ -25697,6 +25688,22 @@ <h4 id="_repl_commands">10.3.1. REPL commands</h4>
</ul>
</div>
<div class="paragraph">
<p>Furthermore, the <strong>'!'</strong> character can also be used to execute an
external command using <strong>sh(1)</strong>. For instance,</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="scheme"><span class="nv">stklos&gt;</span> <span class="nv">!pwd</span>
<span class="nv">/tmp/test</span>
<span class="nv">stklos&gt;</span> <span class="nv">!emacs</span> <span class="nv">foo</span><span class="o">.</span><span class="nv">stk</span> <span class="nv">&amp;</span> <span class="c1">;; to launch emacs on file foo.stk</span>
<span class="nv">stklos&gt;</span> <span class="p">(</span><span class="k">define</span> <span class="nv">!pwd</span> <span class="mi">100</span><span class="p">)</span>
<span class="c1">;; !pwd</span>
<span class="nv">stklos&gt;</span> <span class="nv">!pwd</span> <span class="c1">;; now !pwd overrides pwd(1)</span>
<span class="mi">100</span>
<span class="nv">stklos&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><a id='P_repl-add-command'></a>
</p>
</div>
Expand Down
23 changes: 18 additions & 5 deletions doc/refman/custom.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GFDL-1.3-or-later
//
// Copyright © 2000-2023 Erick Gallesio <[email protected]>
// Copyright © 2000-2024 Erick Gallesio <[email protected]>
//
// Author: Erick Gallesio [[email protected]]
// Creation date: 26-Nov-2000 18:19 (eg)
Expand Down Expand Up @@ -66,10 +66,7 @@ of available commands is given below.

- **,backtrace** (or **,bt**): Show the stack when last error occurred
- **,cd**: Change current directory
- **,pwd**: Print working directory
- **,ls**: List directory content
- **,quit** (or **,q**): Exit STklos
- **,shell** (or **,!**): Run a shell command
- **,time** (or **,t** ): Print the time used to run the next expression
- **,describe** (or **,d**): Describe an object
- **,expand** (or **,e**): Pretty print the macro expansion of a form
Expand All @@ -83,6 +80,23 @@ of available commands is given below.
- **,help** (or **,?** or **,h*): Show help on REPL command with
parameter. With a parameter, display the help of this parameter

Furthermore, the **'!'** character can also be used to execute an
external command using *sh(1)*. For instance,

```scheme
stklos> !pwd
/tmp/test
stklos> !emacs foo.stk & ;; to launch emacs on file foo.stk
stklos> (define !pwd 100)
;; !pwd
stklos> !pwd ;; now !pwd overrides pwd(1)
100
stklos>
```




{{insertdoc 'repl-add-command}}

==== REPL variables
Expand Down Expand Up @@ -115,4 +129,3 @@ The following parameter objects can be used to customize the REPL:

{{insertdoc 'repl-theme}}
{{insertdoc 'repl-show-startup-message}}

8 changes: 4 additions & 4 deletions lib/repl.stk
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ doc>
(repl-add-command '(apropos a)
"Search for symbols containing a given string"
(lambda () (print (apropos (simple-trim (read-line))))))
;; == version
(repl-add-command '(version v)
"Show version"
(lambda () (printf "~a ~a~%" (version) (%push-id))))
;; ==== help
(repl-add-command
'(help ? h)
Expand All @@ -291,10 +295,6 @@ doc>
(display-repl-command-help)
(help (read-from-string arg))))))

;; == version
(repl-add-command '(version v)
"Show version"
(lambda () (printf "~a ~a~%" (version) (%push-id))))
) ;; end of REPL commands

;; ----------------------------------------------------------------------
Expand Down
72 changes: 36 additions & 36 deletions src/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2300,13 +2300,13 @@ char* STk_boot_consts = "#("
"(apropos a)" " "
"\"Search for symbols containing a given string\"" " "
"apropos" " "
"(version v)" " "
"\"Show version\"" " "
"\"~a ~a~%\"" " "
"(help ? h)" " "
"\"This help if no parameter, or help on its argument\"" " "
"\"\"" " "
"help" " "
"(version v)" " "
"\"Show version\"" " "
"\"~a ~a~%\"" " "
"%other-error-handlers" " "
"%try-matching-condition" " "
"%add-error-to-repl-handler" " "
Expand Down Expand Up @@ -62472,6 +62472,32 @@ STk_instr STk_boot_code [] = {
0x55,
0x8f6,
0x23,
0x10,
0x0,
0x25,
0x55,
0x8f7,
0x25,
0x56,
0x1bf,
0x0,
0x6e,
0x56,
0x4c2,
0x0,
0x73,
0x44c,
0x3,
0x24,
0x71,
0x8bb,
0x3,
0x25,
0x55,
0x8f8,
0x55,
0x8f9,
0x23,
0x1d,
0x0,
0x25,
Expand All @@ -62484,7 +62510,7 @@ STk_instr STk_boot_code [] = {
0x1,
0x65,
0x9,
0x8f7,
0x8fa,
0x64,
0x5,
0x25,
Expand All @@ -62499,34 +62525,8 @@ STk_instr STk_boot_code [] = {
0x3b6,
0x1,
0x73,
0x8f8,
0x1,
0x24,
0x71,
0x8bb,
0x3,
0x25,
0x55,
0x8f9,
0x55,
0x8fa,
0x23,
0x10,
0x0,
0x25,
0x55,
0x8fb,
0x25,
0x56,
0x1bf,
0x0,
0x6e,
0x56,
0x4c2,
0x0,
0x73,
0x44c,
0x3,
0x1,
0x24,
0x71,
0x8bb,
Expand Down Expand Up @@ -65623,7 +65623,7 @@ STk_instr STk_boot_code [] = {
0xffff,
0x25,
0x6a,
0x8f8,
0x8fb,
0x2b,
0x1,
0x25,
Expand All @@ -65635,7 +65635,7 @@ STk_instr STk_boot_code [] = {
0x2,
0x65,
0xa,
0x8f8,
0x8fb,
0x62,
0xd,
0x25,
Expand All @@ -65644,7 +65644,7 @@ STk_instr STk_boot_code [] = {
0x55,
0x989,
0x55,
0x8f8,
0x8fb,
0x55,
0x993,
0x6c,
Expand All @@ -65653,15 +65653,15 @@ STk_instr STk_boot_code [] = {
0x24,
0x25,
0x6a,
0x8f8,
0x8fb,
0x75,
0x100,
0x6c,
0x3d,
0x2,
0x24,
0x1f,
0x8f8,
0x8fb,
0x23,
0x28,
0xffff,
Expand Down

0 comments on commit 1307c63

Please sign in to comment.