@@ -71,25 +71,23 @@ func (ts *TestScript) cmdCd(neg bool, args []string) {
7171}
7272
7373func (ts * TestScript ) cmdChmod (neg bool , args []string ) {
74- if len ( args ) != 2 {
75- ts .Fatalf ("usage: chmod mode file " )
74+ if neg {
75+ ts .Fatalf ("unsupported: ! chmod " )
7676 }
77- mode , err := strconv .ParseInt (args [0 ], 8 , 32 )
78- if err != nil {
79- ts .Fatalf ("bad file mode %q: %v" , args [0 ], err )
77+ if len (args ) != 2 {
78+ ts .Fatalf ("usage: chmod perm paths..." )
8079 }
81- if mode > 0777 {
82- ts .Fatalf ("unsupported file mode %.3o" , mode )
80+ perm , err := strconv .ParseUint (args [0 ], 8 , 32 )
81+ if err != nil || perm & uint64 (os .ModePerm ) != perm {
82+ ts .Fatalf ("invalid mode: %s" , args [0 ])
8383 }
84- err = os . Chmod ( ts . MkAbs ( args [1 ]), os . FileMode ( mode ))
85- if neg {
86- if err == nil {
87- ts . Fatalf ( "unexpected chmod success" )
84+ for _ , arg := range args [1 :] {
85+ path := arg
86+ if ! filepath . IsAbs ( path ) {
87+ path = filepath . Join ( ts . cd , arg )
8888 }
89- return
90- }
91- if err != nil {
92- ts .Fatalf ("unexpected chmod failure: %v" , err )
89+ err := os .Chmod (path , os .FileMode (perm ))
90+ ts .Check (err )
9391 }
9492}
9593
0 commit comments