Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to access a configuration file from a Makefile, and thus seek for a short-readable-maintanable way of doing. The file is a python ConfigParser compliant file.

#foo.cfg
[foo]
bar = baz

I use this python oneliner which I found cumbersome

python -c "import ConfigParser; config = ConfigParser.ConfigParser(); config.read('foo.cfg');print config.get('foo','bar')"

Since it is the same format used in git config files, I noticed that git config -f foo.cfg --get foo.bar might do the job, but (1) my section name got an underscore, which is not supported by git-config, and (2) it adds an heavy build dependancy for weird and accessory purpose .

I have seen this format used so many time that I think it might exists a better way.

My questions are:

  • does this config format get a name ? (which might help for web search)
  • is there any standard CLI tools (as simple as git-config) to read these files?
share|improve this question
1  
That looks like an "INI file" format. You may want to write a wrapper-function (or script) so that you can simplify your Makefile commands. See ajdiaz.wordpress.com/2008/02/09/bash-ini-parser –  RedGrittyBrick Oct 23 '12 at 10:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.