Page MenuHomeFreeBSD

Fix indentation in bsdinstall-created wpa_supplicant.conf
ClosedPublic

Authored by dteske on Feb 11 2020, 10:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 6 2024, 4:45 AM
Unknown Object (File)
Jan 11 2024, 3:15 AM
Unknown Object (File)
Dec 27 2023, 10:55 AM
Unknown Object (File)
Dec 20 2023, 4:08 AM
Unknown Object (File)
Nov 20 2023, 9:09 AM
Unknown Object (File)
Sep 30 2023, 6:03 PM
Unknown Object (File)
Aug 31 2023, 7:01 AM
Unknown Object (File)
Aug 21 2023, 1:18 PM
Subscribers

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

Lint
Lint Skipped
Unit
Tests Skipped

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

Ping?

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