Different Results through Automator

Being a scripting novice, I've hacked together a script that uses a command line utility to read maverick tags and then manipulates the output and send Evernote an email with the tags and the file.
When running the following script through Automator (as a Bash script):
I get the expected following output:
However, when I run the same script using Hazel, I get the follow unexpected result:
Not knowing the particular of the tag utility (https://github.com/jdberry/tag), does anyone know what could be effecting the results in Hazel?
Thanks
Ryan
When running the following script through Automator (as a Bash script):
- Code: Select all
#Set the name of the destination Evernote notebook
notebook="setnotebooknamehere"
#Set the name of the destination Evernote notebook
enemail="you@email.com"
#Grab the file tags (using 'Tags') and store them in variable 'mavtags'
mavtags=$(/usr/local/bin/tag --no-name * "$1")
#Manipulate $mavtags var to create hashtags
hashtags=$(echo $mavtags | tr ',' '\n' | sed -e 's/^/#/')
#convert multiline $hashtags to single line var $entags
entags=$(echo $hashtags | sed ':a;N;$!ba;s/\n/ /g')
#creating the name of the note
#remove the filepath
filename=$(n)
extension="${filename##*.}"
filename="${filename%.*}"
#Compose and send email using Mutt
/usr/local/bin/mutt -s "$filename @$notebook $entags" $enemail -a "$1" < /dev/null
I get the expected following output:
@setnotebooknamehere #Yellow
However, when I run the same script using Hazel, I get the follow unexpected result:
@setnotebooknamehere #invoice 2014/15 #Blue #tax 2014 #hazproc #invoice receipt #tax Yellow #swipe invoice #paid #paypal #s 2014/13 #Blue #receipt inbox 2014 #hazproc #invoice 2014 #hazproc #invoice 2014 #hazproc #invoice 2014 #hazproc 2014 #haz
Not knowing the particular of the tag utility (https://github.com/jdberry/tag), does anyone know what could be effecting the results in Hazel?
Thanks
Ryan