Reputation: 33
I have following pre-commit hook:
#!/bin/bash
set -e
result=''
for file in $(find rest/src/main/groovy/ru/naumen/modules -name '*.groovy' | sort); do
filename=basename "$file"
result+=echo "${filename//.groovy/}",
done
result+='smpUtils'
sed -i -r "s|modules = .*|modules = $result|g" rest/smpsync.ini
git add rest/smpsync.ini
I'm getting Permission denied
error on line 8
filename=basename "$file"
And I'm not able to determine the reason of it.
Hook itself has execution rights (chmod +x .git/hooks/pre-commit
)
Whole directories/files tree in ./rest/src/main/groovy/ru/naumen/modules
has read/write rights and belongs to my user.
Upvotes: 1
Views: 7317
Reputation: 33
Issue #1 was as mentioned by @VonC in variable assignment
filename=basename "$file"
-> filename=$(basename "$file")
Issue #2 was in line #9 (I just removed echo
):
result+=echo "${filename//.groovy/}",
-> result+="${filename//.groovy/}",
Upvotes: 1
Reputation: 1324228
Try instead:
filename="$(basename "$file")"
In order to get the result of the command basename
in your filename
variable.
Upvotes: 1