Only throw for specific special built-in errors.

* gash/shell.scm (sh:exec-let): Do not throw on special built-in
errors.
* gash/built-ins/break.scm (main),
gash/built-ins/continue.scm (main),
gash/built-ins/return.scm (main),
gash/built-ins/shift.scm (main): Throw on error.
This commit is contained in:
Timothy Sample 2019-11-26 20:50:45 -05:00
parent 6990d656bc
commit d6a582f1bd
5 changed files with 9 additions and 12 deletions

View File

@ -35,7 +35,7 @@
(match (string->positive-integer arg)
(#f (format (current-error-port)
"gash: break: argument must be a positive integer~%")
EXIT_FAILURE)
(throw 'shell-error))
(n (set-status! 0)
(sh:break (1- n))
(format (current-error-port)
@ -43,4 +43,4 @@
EXIT_SUCCESS)))
(_ (format (current-error-port)
"gash: break: too many arguments~%")
EXIT_FAILURE)))
(throw 'shell-error))))

View File

@ -35,7 +35,7 @@
(match (string->positive-integer arg)
(#f (format (current-error-port)
"gash: continue: argument must be a positive integer~%")
EXIT_FAILURE)
(throw 'shell-error))
(n (set-status! 0)
(sh:continue (1- n))
(format (current-error-port)
@ -43,4 +43,4 @@
EXIT_SUCCESS)))
(_ (format (current-error-port)
"gash: continue: too many arguments~%")
EXIT_FAILURE)))
(throw 'shell-error))))

View File

@ -35,7 +35,7 @@
(match (string->exit-status arg)
(#f (format (current-error-port)
"gash: return: argument must be a number from 0 to 255~%")
EXIT_FAILURE)
(throw 'shell-error))
(n (sh:return n)
(format (current-error-port)
(string-append "gash: return: no function "
@ -43,4 +43,4 @@
EXIT_SUCCESS)))
(_ (format (current-error-port)
"gash: return: too many arguments~%")
EXIT_FAILURE)))
(throw 'shell-error))))

View File

@ -44,8 +44,8 @@
(format (current-error-port)
"~a: shift: Invalid option ~s.~%"
(car (program-arguments)) n-string)
EXIT_FAILURE))))
(throw 'shell-error)))))
(_ (format (current-error-port)
"~a: shift: Invalid options ~s.~%"
(car (program-arguments)) args)
EXIT_FAILURE)))
(throw 'shell-error))))

View File

@ -131,10 +131,7 @@ environment variable bindings @var{bindings}."
((name . value)
(setvar! name value)))
bindings)
(let ((exit-val (apply proc args)))
(unless (= exit-val EXIT_SUCCESS)
(throw 'shell-error))
(set-status! exit-val))))
(set-status! (apply proc args))))
(and=> (getfun name)
(lambda (proc)
(save-variables-excursion (map car bindings)