mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
7.16k stars 338 forks source link

all: consider changes for error wrapping #736

Open mvdan opened 2 years ago

mvdan commented 2 years ago

Error wrapping came with Go 1.13, so we're a bit late to adapt to it. At least, we should allow the user to unwrap internal errors from the errors returned by the parser or interpreter.

We also have thewe two APIs that should probably be deprecated in favor of something more idiomatic given error wrapping:

interp/api.go:479:func IsExitStatus(err error) (status uint8, ok bool) {
syntax/parser.go:753:func IsIncomplete(err error) bool {

For example, the latter should probably be errors.Is(err, io.ErrUnexpectedEOF) instead.