Bug? Apple Script causes Error and crashes hazel

I tried to use an apple script today and it got me an error message when I tried to run it in a hazel rule as a file and embedded as well. The script works fine when run in the script editor. When trying it out several times via "run rules now", hazel put out an error message and when handling the rule, trying to fix it, hazel crashed several times. To make this clear: it didn't crash while trying to execute, it crashed when I double clicked the rule, pasted the apple script text into the embedded script text field, etc. And with crashed I here mean "the application System Preferences" quit unexpectedly..."
The script looks like this:
_______________________
tell application "Mail" to quit
set sizeBefore to do shell script "ls -lah ~/Library/Mail | grep -E 'Envelope Index$' | awk {'print $5'}"
do shell script "/usr/bin/sqlite3 ~/Library/Mail/'Envelope Index' vacuum"
set sizeAfter to do shell script "ls -lah ~/Library/Mail | grep -E 'Envelope Index$' | awk {'print $5'}"
display dialog ("Mail index before: " & sizeBefore & return & "Mail index after: " & sizeAfter & return & return & "Enjoy the new speed!")
tell application "Mail" to activate
_______________________
I got it to work now by slimming the script down to this:
_______________________
tell application "Mail" to quit
do shell script "/usr/bin/sqlite3 ~/Library/Mail/'Envelope Index' vacuum"
tell application "Mail" to activate
_______________________
This is all I need so I consider the problem as solved for me, just wanted to post it in case it has relevance as a bug.
best,
V
The script looks like this:
_______________________
tell application "Mail" to quit
set sizeBefore to do shell script "ls -lah ~/Library/Mail | grep -E 'Envelope Index$' | awk {'print $5'}"
do shell script "/usr/bin/sqlite3 ~/Library/Mail/'Envelope Index' vacuum"
set sizeAfter to do shell script "ls -lah ~/Library/Mail | grep -E 'Envelope Index$' | awk {'print $5'}"
display dialog ("Mail index before: " & sizeBefore & return & "Mail index after: " & sizeAfter & return & return & "Enjoy the new speed!")
tell application "Mail" to activate
_______________________
I got it to work now by slimming the script down to this:
_______________________
tell application "Mail" to quit
do shell script "/usr/bin/sqlite3 ~/Library/Mail/'Envelope Index' vacuum"
tell application "Mail" to activate
_______________________
This is all I need so I consider the problem as solved for me, just wanted to post it in case it has relevance as a bug.
best,
V