set: Support clumped flags, e.g. set -eux.

* gash/built-ins/set.scm (main): Support clumped flags.
This commit is contained in:
Jan Nieuwenhuizen 2018-12-31 17:35:56 +01:00 committed by Timothy Sample
parent 50473ac9d4
commit 25597a4bec
1 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,6 @@
;;; Gash -- Guile As SHell
;;; Copyright © 2018 Timothy Sample <samplet@ngyro.com>
;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of Gash.
;;;
@ -18,6 +19,7 @@
(define-module (gash built-ins set)
#:use-module (gash environment)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match))
;;; Commentary:
@ -79,6 +81,14 @@
EXIT_FAILURE))))
((op . args)
(match (string->list op)
((#\- (? option-letter? chr) ...)
(for-each (cut setopt! <> #t)
(map (cut assoc-ref *option-letters* <>) chr))
EXIT_SUCCESS)
((#\+ (? option-letter? chr) ...)
(for-each (cut setopt! <> #f)
(map (cut assoc-ref *option-letters* <>) chr))
EXIT_SUCCESS)
((#\- (? option-letter? chr))
(setopt! (assoc-ref *option-letters* chr) #t)
(loop args))