Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ifup-routes: print warning when ADDRESS0 entry is missing #475

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions network-scripts/ifup-routes
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
handle_file () {
. $1
routenum=0

# print a warning if ADDRESS is not starting at ADDRESS0
if [ "x$(eval echo '$'ADDRESS$routenum)x" == "xx" ]; then

Check warning

Code scanning / shellcheck

Avoid x-prefix in comparisons as it no longer serves a purpose. Warning

Avoid x-prefix in comparisons as it no longer serves a purpose.
Copy link
Member

@lnykryn lnykryn Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks, fine but two small nitpicks for the future. Since the routenum is always 0, the whole eval shenanigan is unnecessary. Simple [ -z "$ADDRESS0" ] would be much nicer.

net_log $"Route entries are not sequentially ordered. Skipping $1 file" warning
exit 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THis can potentially change the behaviour.

fi

while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum))
line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
Expand Down