Page MenuHomeFreeBSD

os-release: Quote variables as documented in the manual
ClosedPublic

Authored by 0mp on Tue, Nov 23, 10:29 AM.

Details

Reviewers
imp
glebius
Summary

Variables must be quoted if they contain non-alphanumeric characters.

MFC after: 7 days

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 42933
Build 39821: arc lint + arc unit

Event Timeline

0mp requested review of this revision.Tue, Nov 23, 10:29 AM
0mp created this revision.

From the standard:

The application shall quote the following characters if they are to represent themselves:

& ; < > ( ) $ ` \ " ' <space> <tab> <newline>

and the following may need to be quoted under certain circumstances. That is, these characters may be special depending on conditions described elsewhere in this volume of POSIX.1-2017:

  • ? [ # ˜ = %

None of these are possible with the freebsd-version -u output. A number of other things break if people use 'custom' release names with spaces in them...
I'm OK with this change, but the need to do it seems quite low and edge-casey.

This revision is now accepted and ready to land.Tue, Nov 23, 3:52 PM

Seems legit, but I'm not expert in this area.

In D33092#747700, @imp wrote:

From the standard:

The application shall quote the following characters if they are to represent themselves:

& ; < > ( ) $ ` \ " ' <space> <tab> <newline>

and the following may need to be quoted under certain circumstances. That is, these characters may be special depending on conditions described elsewhere in this volume of POSIX.1-2017:

  • ? [ # ˜ = %

None of these are possible with the freebsd-version -u output. A number of other things break if people use 'custom' release names with spaces in them...
I'm OK with this change, but the need to do it seems quite low and edge-casey.

I absolutely agree that it does not matter from sh(1) perspective, but the manual page says that non-alphanumeric values must be quoted. Maybe there is software out there that relies on that. This is rather unlikely. Nevertheless, being consistent with out own documentation is definitely worth the effort. Ubuntu for example quotes those values as documented.

In D33092#748046, @0mp wrote:
In D33092#747700, @imp wrote:

From the standard:

The application shall quote the following characters if they are to represent themselves:

& ; < > ( ) $ ` \ " ' <space> <tab> <newline>

and the following may need to be quoted under certain circumstances. That is, these characters may be special depending on conditions described elsewhere in this volume of POSIX.1-2017:

  • ? [ # ˜ = %

None of these are possible with the freebsd-version -u output. A number of other things break if people use 'custom' release names with spaces in them...
I'm OK with this change, but the need to do it seems quite low and edge-casey.

I absolutely agree that it does not matter from sh(1) perspective, but the manual page says that non-alphanumeric values must be quoted. Maybe there is software out there that relies on that. This is rather unlikely. Nevertheless, being consistent with out own documentation is definitely worth the effort. Ubuntu for example quotes those values as documented.

I guess I'm not clear which documentation you are referring to...