Add support for $$

* geesh/environment.scm (*root-pid*): New variable.
(get-root-pid): New public function.
* geesh/word.scm (parameter-ref): Handle '$'.
This commit is contained in:
Timothy Sample 2018-12-05 13:58:34 -05:00
parent 6b38897dc5
commit 177953c4b0
2 changed files with 8 additions and 1 deletions

View File

@ -23,6 +23,7 @@
#:use-module (srfi srfi-26)
#:export (get-status
set-status!
get-root-pid
getvar
setvar!
unsetvar!
@ -60,7 +61,7 @@
;;; Code:
;;; Status.
;;; Status and PID.
(define *status* 0)
@ -72,6 +73,11 @@
"Set the current status."
(set! *status* n))
(define *root-pid* (getpid))
(define (get-root-pid)
*root-pid*)
;;; Variables.

View File

@ -230,6 +230,7 @@ the environment. If @var{name} is unset, return @code{#f}."
("0" (car (program-arguments)))
("#" (number->string (length (cdr (program-arguments)))))
("?" (number->string (get-status)))
("$" (number->string (get-root-pid)))
(x (let ((n (string->number x)))
(if (and n (integer? n) (> n 0)
(<= n (length (cdr (program-arguments)))))