1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/bash input='/usr/share/libalpm/hooks/90-linux.hook' target=$( grep -m1 'Target = ' "${input}" | \ cut -d'=' -f2 | \ sed 's|\s\+||g' ) sed ' /Description =/{ s/=\s*/= Test permissions for / a When = PreTransaction\ Exec = /usr/bin/sh -c '"'"'[ -w /'"${target}"' ]'"'"'\ AbortOnFail q } ' "${input}"