Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jimmy43

macrumors regular
Original poster
Apr 9, 2008
105
82
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!
 
just to be clear, this works when saved as a bash script, but doesnt work as an automator app/script.
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.