Page MenuHomeFreeBSD

Fix indentation in bsdinstall-created wpa_supplicant.conf
ClosedPublic

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

Details

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

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

emaste created this revision.Feb 11 2020, 10:08 PM
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
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.Feb 14 2020, 11:01 PM

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

dteske added a comment.Mar 2 2020, 6:27 PM

Ping?

Haven't forgotten ... just delayed.

dteske commandeered this revision.Wed, May 20, 8:59 PM
dteske edited reviewers, added: emaste; removed: dteske.

Pre-update commandeer

This revision now requires review to proceed.Wed, May 20, 8:59 PM
dteske updated this revision to Diff 72048.Wed, May 20, 9:00 PM
dteske edited the summary of this revision. (Show Details)

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

allanjude accepted this revision.Wed, May 20, 9:06 PM

Reviewed By: allanjude

This revision is now accepted and ready to land.Wed, May 20, 9:06 PM
This revision was automatically updated to reflect the committed changes.