Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Dec 2010 19:08:16 +0100
From:      Polytropon <freebsd@edvax.de>
To:        Chris Brennan <xaero@xaerolimit.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Well, I broke it! FreeBSD V8.1 release
Message-ID:  <20101222190816.e6932925.freebsd@edvax.de>
In-Reply-To: <AANLkTim%2BCZDVeTzKu1nNmYru54ZQJGQhr3x5AJmeoY0j@mail.gmail.com>
References:  <4D11DA76.32672.214EF771@dave.g8kbv.demon.co.uk> <20101222130711.00006546@unknown> <AANLkTim%2BCZDVeTzKu1nNmYru54ZQJGQhr3x5AJmeoY0j@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 22 Dec 2010 09:49:46 -0500, Chris Brennan <xaero@xaerolimit.net> wrote:
> On Wed, Dec 22, 2010 at 8:07 AM, Bruce Cran <bruce@cran.org.uk> wrote:
> 
> > On Wed, 22 Dec 2010 11:01:10 -0000
> > "Dave" <dave@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

	: << DELIMITER
		... pile ...
		...  of  ...
		... text ...
	DELIMITER

is indirectly refered to in "man sh":

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

      [n]<< delimiter
            here-doc-text
            ...
      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

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

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
algorithms.

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



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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101222190816.e6932925.freebsd>