From 177953c4b08684e775c85dc1d8eb0dc2167f9de9 Mon Sep 17 00:00:00 2001 From: Timothy Sample Date: Wed, 5 Dec 2018 13:58:34 -0500 Subject: [PATCH] Add support for $$ * geesh/environment.scm (*root-pid*): New variable. (get-root-pid): New public function. * geesh/word.scm (parameter-ref): Handle '$'. --- geesh/environment.scm | 8 +++++++- geesh/word.scm | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/geesh/environment.scm b/geesh/environment.scm index e2ec8ee..784a47f 100644 --- a/geesh/environment.scm +++ b/geesh/environment.scm @@ -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. diff --git a/geesh/word.scm b/geesh/word.scm index bc01caa..07de26f 100644 --- a/geesh/word.scm +++ b/geesh/word.scm @@ -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)))))