I have a part of my script that does this:
- Removes everything in directory
- Force syncs from perforce that directory
- copies files from another directory to said directory, of which there are some conflicts that the source control prevent from being overwritten (which is expectable and what I want)
Before I would have just this:
...
cp <source path> <dest path>
echo done copying
...
echo done
Output:
...
Permission Denied:file1
Permission Denied:file2
done copying
...
done
So, it would do the stuff, and reach done. Then, I went and made a sort of check to make sure the directory exits like so:
if[ -d sourcepath ]
then
if [ -d destpath ]
then
cp <source path> <dest path>
else
echo problem with dest
exit 1
fi
else
problem with source
exit 1
fi
But now the script just exits after the last of the Permission Denies, not hitting anything after, so the output is like this:
Output:
...
Permission Denied:file1
Permission Denied:file2
I'm not too savvy in the bash rules, so I just thought I'd post this question here since I couldn't find it. It seems that in the if, though, the fact that there are permission problems cause it to exit.