PDA

View Full Version : Simple bash/automator question




jimmy43
Nov 20, 2009, 06:35 PM
I am setting up a script which minifies and concatenates a bunch of css/js files.

So in my script i have this:

csslist=`find $1 -type f -name \*.css -a \! -name \*.min.css`
for cfile in $csslist
do
cfilemini="${cfile%.css}.min.css"
echo "Minifying $cfile..."
java -jar $YUICOMPRESSOR --type css $ARGS $cfile -o $cfilemini
cat $cfilemini >> compressed.css
done

but the cat $cfilemini >> compressed.css doesn't work. Are you allowed redirection in this type of script? It's just bash ...

thanks!



jimmy43
Nov 20, 2009, 06:46 PM
just to be clear, this works when saved as a bash script, but doesnt work as an automator app/script.

chown33
Nov 21, 2009, 01:02 PM
java -jar $YUICOMPRESSOR --type css $ARGS $cfile -o $cfilemini
cat $cfilemini >> compressed.css

In both commands, $cfilemini is unquoted. So are $YUICOMPRESSOR and $cfile. Think about what happens if any of those values has spaces embedded in the pathname.

As a test, run your shell script using a pathname that contains embedded spaces.

You might also describe exactly what happens when it doesn't work. Post any error messages, unexpected files, missing files, etc.