Solved [Solved] Configuration Files

Hello,

I am new to FreeBSD and have several questions about configuration files. I've looked for the answers through multiple searches and forum posts but haven't found them, although that may be because I haven't used the right search terms. Any answers as well as suggestions on how to find answers to questions such as this would be much appreciated.

Numerical values as in the example below are not quoted because they are not text - they are numerical values... is that correct? Or does quoting them do anything?

Code:
kern.hz=100

I am also confused by having seen different styles and capitalization, with an arbitrary example below:
Code:
WITH_NEW_XORG=YES

My questions here are:
1) Does capitalization matter on either side of the "=" sign, and if not, is there an "official" or preferred style?
2) What are the differences between using "YES" or "ON" or "TRUE"? Is one form "better" than the others?
3) Some files use "NO" or "OFF" or "FALSE". Why is it explicitly spelled out in some cases and not others, and again, is one form "better" than the other?

Finally, some configuration files mention using tabs over spaces, while others do not. If I don't intend to migrate my configuration files to other operating systems, does it make any difference as a practical matter which one I choose?

Thank you in advance for any help you can give me.

ES
 
Re: Configuration Files

ExpatSailor said:
Hello,

I am new to FreeBSD and have several questions about configuration files. I've looked for the answers through multiple searches and forum posts but haven't found them, although that may be because I haven't used the right search terms. Any answers as well as suggestions on how to find answers to questions such as this would be much appreciated.

Numerical values as in the example below are not quoted because they are not text - they are numerical values... is that correct? Or does quoting them do anything?

Code:
kern.hz=100

No, in this case they don't do anything. Because these are just shell scripts, the quotes are not required unless there are spaces in the values. The values in /etc/rc.conf are usually quoted, but it's not required. Values in /boot/loader.conf are not as consistent.

I am also confused by having seen different styles and capitalization, with an arbitrary example below:
Code:
WITH_NEW_XORG=YES

My questions here are:
1) Does capitalization matter on either side of the "=" sign, and if not, is there an "official" or preferred style?

On the left side, yes, case is significant. The value assigned on the right side... sometimes yes, sometimes no. Many variables are tested just for their presence, so
Code:
WITH_NEW_XORG=qpeowriu
could also work. For that type of variable, setting the value to NO does not act as expected. The variable is still defined, and seen as true.

2) What are the differences between using "YES" or "ON" or "TRUE"? Is one form "better" than the others?

It only depends on what values are expected. /etc/rc.conf can take YES or NO values in upper or lower case, but upper case is the standard.

3) Some files use "NO" or "OFF" or "FALSE". Why is it explicitly spelled out in some cases and not others, and again, is one form "better" than the other?

No, there aren't any that are better than others. It's just important to use values that are expected.

Finally, some configuration files mention using tabs over spaces, while others do not. If I don't intend to migrate my configuration files to other operating systems, does it make any difference as a practical matter which one I choose?

Whitespace is usually ignored, but it varies between files. There are some example files in /usr/share/examples.
 
Re: Configuration Files

Hello,

Thank you for your quick, very helpful reply.

Just to make sure that I understand you properly, I have a couple of follow-up questions, if you don't mind.

The overall understanding that I get from your reply is the required use of capitalization, quotes, and values varies among and even inside the various configuration files, with the exception that capitalization is always significant on the left-hand side of the "=" sign. If that is the case, is it best to copy verbatim the examples in the example files and Handbook and other documentation, or is there documentation somewhere that provides specific details about all of this?

I'm puzzled when you say that because these are shell scripts, values aren't required to have quotes around them unless they have spaces in them. Don't shell scripts have to be parsed like any other program, and the type of variable determined, as well as the value of that variable? Or does the shell expect a certain kind of variable -- text or integer -- and thus it doesn't need to be defined explicitly?

For the sake of background, I am interested in using FreeBSD to learn about Unix as a way of exercising my almost 60 year old brain. More practically, I'm also interested in learning to use AsciiDoc, which I was motivated to do from seeing your site. I am not a "natural" at anything computer- or programming related, so I don't often make those intuitive "jumps" that others might make.

Although it's a topic for another forum, I'm having trouble getting xorg and xfce4 to work properly (Intel HD 2000 graphics), and I decided to upgrade from the 10.0 Release to Stable. The short version of how to do it on your site was a great help, and I was up and running in no time, so many thanks for that.

ES
 
Re: Configuration Files

Not all of these files are executed as shell scripts, but /etc/rc.conf is. sh(1) variables are untyped. There is no difference between these examples:
Code:
sample="1"
sample=1

Spaces are significant, though:
Code:
% cat tester.sh
#!/bin/sh

sample=a b c
echo $sample
sample="a b c"
echo $sample
% ./tester.sh
./tester.sh: b: not found

a b c

The first assignment failed because it tried to execute b as a command. The second worked, because the value was enclosed in quotes, making the shell see it as a single value rather than splitting it on spaces.

Oh, and don't add spaces before or after the equals sign for neatness, they change the way sh(1) interprets the value.

Glad to hear that my articles helped!
 
Re: Configuration Files

Your help is much appreciated... thank you. One of the things that make this whole process of learning a Unix-like system is that every answer to a question seems to raise more questions in a never-ending chain, but I'll consider this "solved."
 
Back
Top