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

To add, if you need/want to you can write python and perl inline in bash like so:

  python3 - <<'END'
  print('hello world')
  END
The advantage is that you still have only one shell script to ship, which makes sense when the python code inside it is specific to that one script.

Remember to use the <<'END' variant so variable expansion isn't done inside the heredoc. On the other hand, $ doesn't do anything in python and if you're feeling like it (please make sure everybody else is also feeling like it) you can use variable substitution there, in effect generating a python script and executing it.



Playing around with it, I see that using <<'END' does not expand $variables in the block, but <<END does expand them. My google-fu is failing me; what's happening here?


It's two different syntaxes. Like the difference between '$VAR' (no expansion, literal string) and "$VAR" (with expansion). See

http://tldp.org/LDP/abs/html/quoting.html

http://tldp.org/LDP/abs/html/here-docs.html




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: