1ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari#!/bin/bash 2ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 3ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari# Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com> 4ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari# Copyright 2013 Robin Mittal <robinmittal.it@gmail.com> 5ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 6ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari#testing "name" "command" "result" "infile" "stdin" 7ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 8324a4a018a4e949d2262ca622722948712ec4a4dRob Landleyumask 022 9324a4a018a4e949d2262ca622722948712ec4a4dRob Landley 10d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob LandleyPERM="---""--x""-w-""-wx""r--""r-x""rw-""rwx" 11d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley 12d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landleynum2perm() 13d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley{ 14d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley for i in 0 1 2 15d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley do 16d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley num=${1:$i:1} 17d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley printf "%s" ${PERM:$(($num*3)):3} 18d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley done 19d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley echo 20d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley} 21ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 22ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari# Creating test files to test chmod command 23ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharimkdir dir 24ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitouch file 25ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 26324a4a018a4e949d2262ca622722948712ec4a4dRob Landley# We don't need to test all 512 permissions 27d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landleyfor u in 0 1 2 3 4 5 6 7 28ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharido 29d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley for g in 0 3 6 30ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari do 31d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley for o in 0 7 32ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari do 33d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley if [ "$type" == file ] 34d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley then 35d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley type=dir 36d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley rm -rf "./$type" && mkdir $type 37d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley DASH=d 38d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley else 39d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley type=file 40d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley rm -f "./$type" && touch $type 41d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley DASH=- 42d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley fi 43d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley DASHES=$(num2perm $u$g$o) 44d6f8c41e25428c8a0caf6f52fbe665d3baa06adcRob Landley testing "chmod $u$g$o $type" "chmod $u$g$o $type && 45207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld $type | cut -d' ' -f 1 | cut -d. -f 1" "$DASH$DASHES\n" "" "" 46ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari done 47ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari done 48ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharidone 49ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 50ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 51ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod 750 dir 640 file" \ 52ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari "chmod 750 dir 640 file 2>/dev/null || 53207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-x---\n-rwxr-x---\n" "" "" 54ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 55ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 56ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod 666 dir file" \ 57ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari "chmod 666 dir file && 58207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drw-rw-rw-\n-rw-rw-rw-\n" "" "" 59ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 60ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 61ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod 765 *" "chmod 765 * && 62207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxrw-r-x\n-rwxrw-r-x\n" "" "" 63ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 64ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari##### u,g,o,a=r,w,x 65ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 66ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod u=r dir file" "chmod u=r dir file && 67207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr--r-xr-x\n-r--r--r--\n" "" "" 68ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 69ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 70ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod u=w dir file" "chmod u=w dir file && 71207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-w-r-xr-x\n--w-r--r--\n" "" "" 72ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 73ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 74ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod u=x dir file" "chmod u=x dir file && 75207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d--xr-xr-x\n---xr--r--\n" "" "" 76ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 77ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 78ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod u+r dir file" "chmod u+r dir file && 79207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" 80ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 81ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 82ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod u+w dir file" "chmod u+w dir file && 83207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" 84ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 85ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 86ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod u+x dir file" "chmod u+x dir file && 87207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rwxr--r--\n" "" "" 88ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 89ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 90ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod u-r dir file" "chmod u-r dir file && 91207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-wxr-xr-x\n--w-r--r--\n" "" "" 92ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 93ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 94ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod u-w dir file" "chmod u-w dir file && 95207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr-xr-xr-x\n-r--r--r--\n" "" "" 96ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 97ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 98ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod u-x dir file" "chmod u-x dir file && 99207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drw-r-xr-x\n-rw-r--r--\n" "" "" 100ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 101ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 102ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod g=r dir file" "chmod g=r dir file && 103207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr--r-x\n-rw-r--r--\n" "" "" 104ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 105ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 106ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod g=w dir file" "chmod g=w dir file && 107207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwx-w-r-x\n-rw--w-r--\n" "" "" 108ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 109ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 110ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod g=x dir file" "chmod g=x dir file && 111207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwx--xr-x\n-rw---xr--\n" "" "" 112ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 113ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 114ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod g+r dir file" "chmod g+r dir file && 115207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" 116ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 117ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 118ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod g+w dir file" "chmod g+w dir file && 119207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxrwxr-x\n-rw-rw-r--\n" "" "" 120ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 121ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 122ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod g+x dir file" "chmod g+x dir file && 123207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r-xr--\n" "" "" 124ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 125ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 126ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod g-r dir file" "chmod g-r dir file && 127207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwx--xr-x\n-rw----r--\n" "" "" 128ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 129ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 130ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod g-w dir file" "chmod g-w dir file && 131207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" 132ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 133ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 134ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod g-x dir file" "chmod g-x dir file && 135207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr--r-x\n-rw-r--r--\n" "" "" 136ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 137ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 138ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod o=r dir file" "chmod o=r dir file && 139207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr--\n-rw-r--r--\n" "" "" 140ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 141ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 142ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod o=w dir file" "chmod o=w dir file && 143207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-x-w-\n-rw-r---w-\n" "" "" 144ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 145ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 146ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod o=x dir file" "chmod o=x dir file && 147207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-x--x\n-rw-r----x\n" "" "" 148ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 149ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 150ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod o+r dir file" "chmod o+r dir file && 151207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" 152ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 153ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 154ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod o+w dir file" "chmod o+w dir file && 155207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xrwx\n-rw-r--rw-\n" "" "" 156ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 157ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 158ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod o+x dir file" "chmod o+x dir file && 159207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r-x\n" "" "" 160ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 161ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 162ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod o-r dir file" "chmod o-r dir file && 163207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-x--x\n-rw-r-----\n" "" "" 164ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 165ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 166ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod o-w dir file" "chmod o-w dir file && 167207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" 168ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 169ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 170ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod o-x dir file" "chmod o-x dir file && 171207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr--\n-rw-r--r--\n" "" "" 172ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 173ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 174ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod a=r dir file" "chmod a=r dir file && 175207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr--r--r--\n-r--r--r--\n" "" "" 176ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 177ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 178ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod a=w dir file" "chmod a=w dir file && 179207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-w--w--w-\n--w--w--w-\n" "" "" 180ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 181ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 182ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod a=x dir file" "chmod a=x dir file && 183207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d--x--x--x\n---x--x--x\n" "" "" 184ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 185ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 186ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod a+r dir file" "chmod a+r dir file && 187207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" 188ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 189ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 190ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod a+w dir file" "chmod a+w dir file && 191207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxrwxrwx\n-rw-rw-rw-\n" "" "" 192ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 193ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 194ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod a+x dir file" "chmod a+x dir file && 195207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rwxr-xr-x\n" "" "" 196ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 197ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 198ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod a-r dir file" "chmod a-r dir file && 199207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-wx--x--x\n--w-------\n" "" "" 200ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 201ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 202ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod a-w dir file" "chmod a-w dir file && 203207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr-xr-xr-x\n-r--r--r--\n" "" "" 204ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 205ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 206ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod a-x dir file" "chmod a-x dir file && 207207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drw-r--r--\n-rw-r--r--\n" "" "" 208ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 209ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 210ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod =r dir file" "chmod =r dir file && 211207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr--r--r--\n-r--r--r--\n" "" "" 212ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 213ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 214ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod =w dir file" "chmod =w dir file && 215207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-w-------\n--w-------\n" "" "" 216ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 217ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 218ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod =x dir file" "chmod =x dir file && 219207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d--x--x--x\n---x--x--x\n" "" "" 220ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 221ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 222ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod +r dir file" "chmod +r dir file && 223207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" 224ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 225ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 226ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod +w dir file" "chmod +w dir file && 227207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" 228ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 229ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 230ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod +x dir file" "chmod +x dir file && 231207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rwxr-xr-x\n" "" "" 232ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 233ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 234ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod -r dir file" "chmod -r dir file && 235207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-wx--x--x\n--w-------\n" "" "" 236ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 237ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 238ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod -w dir file" "chmod -w dir file && 239207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr-xr-xr-x\n-r--r--r--\n" "" "" 240ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 241ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file && mkdir dir && touch file 242ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharitesting "chmod -x dir file" "chmod -x dir file && 243207b6a66ba0c225a7977cedcf8537883a434db3eDivya Kothari ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drw-r--r--\n-rw-r--r--\n" "" "" 244ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari 245ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kothari# Removing test files for cleanup purpose 246ef0ed68d5ba5794c1352e64273d4c5039e62476bDivya Kotharirm -rf dir file 247