Page MenuHomeFreeBSD

Fix indentation in bsdinstall-created wpa_supplicant.conf

Authored by dteske on Feb 11 2020, 10:08 PM.



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

rS FreeBSD src repository - subversion
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

dteske requested changes to this revision.Feb 14 2020, 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

Should be (for example):

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

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.Feb 14 2020, 11:01 PM

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


Haven't forgotten ... just delayed.

dteske edited reviewers, added: emaste; removed: dteske.

Pre-update commandeer

This revision now requires review to proceed.May 20 2020, 8:59 PM
dteske edited the summary of this revision. (Show Details)

Indentation fixes. Fix whitespace for consistency. Fix >80c lines.

This revision is now accepted and ready to land.May 20 2020, 9:06 PM