Well, I broke it! FreeBSD V8.1 release

Polytropon freebsd at edvax.de
Wed Dec 22 18:08:20 UTC 2010

On Wed, 22 Dec 2010 09:49:46 -0500, Chris Brennan <xaero at xaerolimit.net> wrote:
> On Wed, Dec 22, 2010 at 8:07 AM, Bruce Cran <bruce at cran.org.uk> wrote:
> > On Wed, 22 Dec 2010 11:01:10 -0000
> > "Dave" <dave at g8kbv.demon.co.uk> wrote:
> >
> > > Sysinstall alows you to select and enable one, but not remove it!
> > >
> > > Bit of an oversight that I suspect....
> >
> > Fixed in r216651 :)
> >
> IIRC ';' isn't a valid bash comment ... (which has been previously discussed
> elsewhere). It's usually safer to use '#' for  comment in /etc/rc.conf and
> other system config files as they typically use BASH style structs.

Putting emphasize on _BA_sh seems to be a typical Linuxism. :-)

FreeBSD's standard scripting shell is the Bourne Shell, /bin/sh.
The Bourne Again Shell, bash, isn't even part of the FreeBSD
(base) system. Only under exceptional circumstances there
will be a /bin/bash.

As it has been pointed out, /etc/rc.conf is a shell script
(or to be correct: part of a shell script) that basically
consists of variable assignments, name="value". In this
context, ; has the default meaning in sh syntax - this
refers to Bourne Shell syntax.

The ; means "command separator". It is a valid syntactical
element of the "sh language". A command like

	; saver="NO"

causes the shell to stop processing the script (which causes
the system boot to stop as it interrupts reading /etc/rc.conf,
which interrupts the start of /etc/rc). Infont of ; there
has to be a command, and in this case, nothing is there.

As the Bourne Shell is the standard scripting shell on most
UNIX systems, relying on bash specific constructs may have
impact to script portability (which may develop into an
issue if you have to create scripts that should run on many
different kinds of UNIX).

The form

		... pile ...
		...  of  ...
		... text ...

is indirectly refered to in "man sh":

The following redirection is often called a ``here-document''.

      [n]<< delimiter

All the text on successive lines up to the delimiter is saved away and
made available to the command on standard input, or file descriptor n if
it is specified.  If the delimiter as specified on the initial line is
quoted, then the here-doc-text is treated literally, otherwise the text
is subjected to parameter expansion, command substitution, and arithmetic
expansion (as described in the section on Word Expansions).  If the oper-
ator is ``<<-'' instead of ``<<'', then leading tabs in the here-doc-text
are stripped.


The option of specifying : as a file descriptor works with
the standard /bin/sh of FreeBSD, but I'm not sure this should
be encouraged for use in configuration files like /etc/rc.conf.

Using the form

	# blah

is also better for use with syntax highlighting as comments
can be determined more easily, whereas the form using the "here-doc"
is primarily a "here-doc" and NOT a comment (unless directed
toward :).

>From "man sh":

The character `#' introduces a comment if used at the beginning of a
word.  The word starting with `#' and the rest of the line are ignored.


The use of # also makes sure there is NO kind of variable
expansion or arithmetic operation done - which you could
achieve using

		... pile ...
		...  of  ...
		... text ...
		$((the)) $USER `/bin/laden` ${causes `NO' touble here!

but # is the really safe form, as you can write ANYTHING
behind it. Again, the form illustrated above could cause
some interpretation problems for syntax highlighting

See "man rc.conf" for details. :-)

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list