var scriptCmds = map[string]func(*testScript, bool, []string){
"addcrlf": (*testScript).cmdAddcrlf,
"cd": (*testScript).cmdCd,
+ "chmod": (*testScript).cmdChmod,
"cmp": (*testScript).cmdCmp,
"cmpenv": (*testScript).cmdCmpenv,
"cp": (*testScript).cmdCp,
fmt.Fprintf(&ts.log, "%s\n", ts.cd)
}
+// chmod changes permissions for a file or directory.
+func (ts *testScript) cmdChmod(neg bool, args []string) {
+ if neg {
+ ts.fatalf("unsupported: ! chmod")
+ }
+ if len(args) < 2 {
+ ts.fatalf("usage: chmod perm paths...")
+ }
+ perm, err := strconv.ParseUint(args[0], 0, 32)
+ if err != nil || perm&uint64(os.ModePerm) != perm {
+ ts.fatalf("invalid mode: %s", args[0])
+ }
+ for _, path := range args[1:] {
+ err := os.Chmod(path, os.FileMode(perm))
+ ts.check(err)
+ }
+}
+
// cmp compares two files.
func (ts *testScript) cmdCmp(neg bool, args []string) {
if neg {
- cd dir
Change to the given directory for future commands.
+- chmod perm path...
+ Change the permissions of the files or directories named by the path arguments
+ to be equal to perm. Only numerical permissions are supported.
+
- cmp file1 file2
Check that the named files have the same content.
By convention, file1 is the actual data and file2 the expected data.