News for hackers. Stuff that matters.
Re:Show HN: Sempl – Stupid Simple Bash Templating by learning_still on Thursday October 08, 2015 @05:06PM (#10356240)
If anyone uses this, please share. As a newb, I would love to see some real use examples to learn from.
Re:Show HN: Sempl – Stupid Simple Bash Templating by nextrevision on Thursday October 08, 2015 @06:07PM (#10356682)
Sure thing, I'm currently using it in docker as a lightweight way to set config files from environment variables. I'll put together a write up of how/why we are doing that and post the link in reply to this.
Re:Show HN: Sempl – Stupid Simple Bash Templating by TomFrost on Thursday October 08, 2015 @09:26PM (#10357564)
Just today I made a suggestion in a Github issue[0] to use sed for a similar use case. There, it was to generate an Amazon ECS task definition file from a CI tool's environment variables. Using this, populating the list of environment variables by looping through the output of env and including anything that matches a given prefix would be a breeze.

Thanks for the excellent tool!

[0]: https://github.com/1science/wercker-aws-ecs/issues/4#issueco...

Re:Show HN: Sempl – Stupid Simple Bash Templating by nextrevision on Thursday October 08, 2015 @10:52PM (#10357881)
Here's the write up. Let me know if there's anything unclear!

http://nextrevision.github.io/2015/sempl-templating-with-bas...

Re:Show HN: Sempl – Stupid Simple Bash Templating by learning_still on Friday October 09, 2015 @01:28AM (#10358347)
This is perfect! Thank you for taking the time to make this. It gave me a much better understanding of what sempl is, how to use it, and what it can be used for.
Re:Show HN: Sempl – Stupid Simple Bash Templating by bashinator on Thursday October 08, 2015 @06:00PM (#10356626)
How is this different from GNU envsubst (in the gettext package)?
Re:Show HN: Sempl – Stupid Simple Bash Templating by nextrevision on Thursday October 08, 2015 @06:13PM (#10356721)
envsubst will really just perform variable substitution, not perform any logic or command substitution (e.g. $(hostname -f)). It's also limited, from what I've seen, in support for other bash variable actions (such as defaults). You can also write loops with output similar to other templating languages here as well.
Re:Show HN: Sempl – Stupid Simple Bash Templating by pdkl95 on Thursday October 08, 2015 @09:41PM (#10357619)
Traditionally, this would be a job for m4:

    $ cat examples/config.yaml.in 
    user: USERNAME
    password: ifelse(PASSWORD,`PASSWORD',`defaultpass',PASSWORD)
    files:
    patsubst(esyscmd(`ls'), `.+$', `  - \&')

    $ m4 -DUSERNAME=somebody examples/config.yaml.in
    user: somebody
    password: defaultpass
    files:
      - README.m4
      - examples
      - sempl