| 1 |
// Copyright (c) 2017, Andrey Nering <[email protected]> |
| 2 |
// See LICENSE for licensing information |
| 3 |
|
| 4 |
//go:build !unix |
| 5 |
|
| 6 |
package interp |
| 7 |
|
| 8 |
import ( |
| 9 |
"context" |
| 10 |
"fmt" |
| 11 |
|
| 12 |
"mvdan.cc/sh/v3/syntax" |
| 13 |
) |
| 14 |
|
| 15 |
func mkfifo(path string, mode uint32) error { |
| 16 |
return fmt.Errorf("unsupported") |
| 17 |
} |
| 18 |
|
| 19 |
// defaultAccess attempts to emulate access(2) on Windows. |
| 20 |
// Windows seems to have a different system of permissions than Unix, |
| 21 |
// so for now just rely on what [io/fs.FileInfo] gives us |
| 22 |
// via the stat handler. |
| 23 |
func defaultAccess(ctx context.Context, path string, mode AccessMode) error { |
| 24 |
info, err := HandlerCtx(ctx).runner.statHandler(ctx, path, false) |
| 25 |
if err != nil { |
| 26 |
return err |
| 27 |
} |
| 28 |
m := info.Mode() |
| 29 |
if mode&AccessRead != 0 && m&0o400 == 0 { |
| 30 |
return fmt.Errorf("file is not readable") |
| 31 |
} |
| 32 |
if mode&AccessWrite != 0 && m&0o200 == 0 { |
| 33 |
return fmt.Errorf("file is not writable") |
| 34 |
} |
| 35 |
if mode&AccessExec != 0 && m&0o100 == 0 { |
| 36 |
return fmt.Errorf("file is not executable") |
| 37 |
} |
| 38 |
return nil |
| 39 |
} |
| 40 |
|
| 41 |
// unTestOwnOrGrp panics. Under Unix, it implements the -O and -G unary tests, |
| 42 |
// but under Windows, it's unclear how to implement those tests, since Windows |
| 43 |
// doesn't have the concept of a file owner, just ACLs, and it's unclear how |
| 44 |
// to map the one to the other. |
| 45 |
func (r *Runner) unTestOwnOrGrp(ctx context.Context, op syntax.UnTestOperator, x string) bool { |
| 46 |
r.errf("unsupported unary test op: %v\n", op) |
| 47 |
return false |
| 48 |
} |
| 49 |
|
| 50 |
// waitStatus is a no-op on plan9 and windows. |
| 51 |
type waitStatus struct{} |
| 52 |
|
| 53 |
// isENOEXEC is a no-op on plan9 and windows. |
| 54 |
func isENOEXEC(err error) bool { return false } |
| 55 |
|
| 56 |
// isETXTBSY is a no-op on plan9 and windows. |
| 57 |
func isETXTBSY(err error) bool { return false } |
| 58 |
|
| 59 |
func (waitStatus) Signaled() bool { return false } |
| 60 |
func (waitStatus) Signal() int { return 0 } |