Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ini file - Refer variable from another ini file

Tags:

ini

How can I parse variable from another ini file?

In following example, I'd like to parse var_a from original_configuration.ini and use it at new_configuration.ini

original_configuration.ini:

[Section A]

var_a = "foo"

var_b = "bar"

new_configuration.ini:

[Section B]

var_c = "lorem"

var_d = {value of var_a in original_configuration.ini}
like image 944
Chemical Programmer Avatar asked Nov 23 '15 08:11

Chemical Programmer


People also ask

Can you use environment variables in INI files?

A variety of environment variables and CCI. INI file entries can be used to customize CCI behavior either on a machine-wide or per-process basis. Most users should not need to use either of these methods, but they are provided in case a greater degree of application control is required.

Can you comment an INI file?

Comments in the INI must start with a semicolon (";") or a hash character ("#"), and run to the end of the line. A comment can be a line of its own, or it may follow a key/value pair (the "#" character and trailing comments are extensions of minIni).

Is INI case sensitive?

ini parameters are now case-insensitive. Their assigned values, however, can be case-sensitive, depending on the platform.

Are INI files still used?

Starting with Windows 95, operating system settings were moved to the Registry, and software vendors were encouaged to move their settings to the Registry as well. However, all subsequent versions of Windows continued support for the creation and use of INI files, and they are still widely used by applications.


1 Answers

Since an INI file is an informal standard it depends on the program which is using the configuration file:

The INI file format is an informal standard for configuration files for some platforms or software. INI files are simple text files with a basic structure composed of sections, properties, and values.

Neither Wikipedia nor Microsoft's page about INI configutariont files mention anything about referring to other properties or other configuration files. However since it is not a formal standard, each configuration parser can have its own variant. This answer for example, shows that Python's configparser package is able to refer to other properties:

[env]
name = DEV

[dir]
home = /home/${env:name}/scripts
like image 161
agold Avatar answered Sep 28 '22 14:09

agold