Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tl;dr I discovered some weird Windows behavior where an invalid path causes
scc.exe
to panic. Surprisingly, the error is not a "does not exist" error. After some thought it seemed better to exit on any non-nil error.In PowerShell, I tried to run
scc.exe *.go
, and to my surprise I got a panic. PowerShell did not expand the glob -- that's not scc's fault, although potentially glob expansion can be added as a feature if that's reasonable. But the issue is that, on Windows, apparently this does not raise a "does not exist" error. Soos.Stat()
returnsnil, err
whereerr
is notnil
. So the call tos.IsDir()
raises a nil pointer dereference error.I did some playing around using the code below:
And here's the result of
go run .\main.go "?"
:Perhaps unexpectedly,
filepath.Clean
does not clean the invalid character?
. Also,CreateFile
is not the op that I would expect 🤔At first I wanted to narrow down to exactly the error type, but then I figured that it should be fine to treat any
os.Stat
error the same, especially with more unusual errors like these.