Page MenuHomeFreeBSD

Fix indentation in bsdinstall-created wpa_supplicant.conf
Needs RevisionPublic

Authored by emaste on Tue, Feb 11, 10:08 PM.

Details

Reviewers
dteske
allanjude
Summary

Issue introduced in rS309934 was partially fixed by rS326094 but still stripped leading tabs. Complete the fix.

PR: 221982
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

emaste created this revision.Tue, Feb 11, 10:08 PM
dteske requested changes to this revision.Fri, Feb 14, 11:01 PM

The purpose of the awk is to trim a single leading-tab from the input.

The reason for doing that is because the input should be indented by a single leading-tab and it is not.

The reason the here-doc text is not indented is because someone is ignoring the fact that we should be indented because we are in an if-then-else-fi block.

This makes the code harder to read. We should improve the readability of the code.

I would actually prefer to change it in this way:

        awk 'sub(/^\t/,"")||1' \
                >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<EOF
network={
        ssid="$NETWORK"
        scan_ssd=$SCANSSID
        key_mgmt=NONE
        priority=5
}
EOF

Should be (for example):

awk 'sub(/^\\/,"")||1' \
        >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
network={
\        ssid="$NETWORK"
\        scan_ssid=$SCANSSID
\        key_mgmt=NONE
\        priority=5
}
EOF

Three things are being done:

  1. Instead of trimming a leading tab, we trim a leading backslash
  2. We change <<EOF to <<-EOF so that leading tabs are eaten
  3. We place a backslash before any leading tab that we want to preserve (for only the first tab where we want the line to start)
This revision now requires changes to proceed.Fri, Feb 14, 11:01 PM

If you have a preferred fix please commandeer this revision and update the new patch.