Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Great article! I could have only wished for such fine introductory material when I was starting off with Make. It would be nice if the docs themselves had a similar chapter.

One thing that I've always wanted from Make was a way of writing long commands with less escaping and without continuation characters. Something like heredoc for Make.

For example, the following is just too arcane and I would by all means move the body of the command into a separate file:

    compress:
      find -iname '*.html' -print0 | \
      while IFS="" read -r -d "" fn; do \
        old=$$(stat -c "%s" "$$fn"); \
        java -jar htmlcompressor.jar "$$fn" -o "$$fn"; \
        new=$$(stat -c "%s" "$$fn"); \
        delta=$$(echo "scale=2 ; 100 - ($$new/$$old) * 100" | bc); \
        echo "compressed $${fn}: $${old}/$${new} $${delta}%"; \
      done;
Assuming there is no interpolation between Make and Bash, why not provide a way of writing the command as naturally as possible:

    compress:
      %cmd -flags -that -control -escaping << EOF
      find -iname '*.html' -print0 | while IFS="" read -r -d "" fn; do
        old=$(stat -c "%s" "${fn}")

        java -jar htmlcompressor.jar "${fn}" -o "${fn}"
        new=$(stat -c "%s" "${fn}")

        delta=$(echo "scale=2 ; 100 - (${new}/${old}) * 100" | bc)
        echo "compressed ${fn}: ${old}/${new} ${delta}%"
      done
      EOF
Of course, shell and Make have a lot of conflicting syntax that would make this into a hard problem.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: