I have ZSH as my default shell and I am using OhMyZsh on top of it. Some times I need to delete some files and reset some permissions/ownership so I am working in an alias for it. Lets say I have a PHP/Symfony project under /home/parallels/Development/prj1. Having the below script I execute it as fixperms prj1 it works but ....
- if I execute the script one time and it deletes the content of
$CURRENT_PROJECT/$PROJECT_CACHEI end up with the following error:
fixperms:4: no matches found: /home/parallels/Development/prj1/framework/var/cache/*
if I remove the
*at the end of$CURRENT_PROJECT/$PROJECT_CACHE/*it deletes thecachefolder which I don't wantthe file
dev.logis never deleted
What I am missing here?
PROJECT=framework
PROJECT_VAR=$PROJECT/var
PROJECT_CACHE=$PROJECT_VAR/cache
PROJECT_LOG=var/log/dev.log
fixperms () {
if [ -n "$1" ]; then
CURRENT_PROJECT=$HOME/Development/"$1"
cd $CURRENT_PROJECT && sudo rm -rf $CURRENT_PROJECT/$PROJECT_CACHE/* && sudo rm -rf $CURRENT_PROJECT/$PROJECT_LOG && sudo chown -R "$(whoami)":root $CURRENT_PROJECT && sudo chmod -R 777 $CURRENT_PROJECT/$PROJECT_VAR
else
echo "Missing project param."
fi
}
Note: I am not a bash/shell script guru so any improvements are more than welcome and appreciate in advance