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

Do not return error from -i when no interfaces are configured #17

Merged
merged 1 commit into from
Apr 21, 2023

Conversation

hramrach
Copy link
Contributor

Thhe -i and -l options have an optional pattern argument, and it makes sense to return an error when the pattern does not match.

However, when no pattern is specified and no interface is configured an error is returned as well.

This makes it problematic to detect if -i option is supported - an error is returned both when the option is not supported by other resolvconf implementation, and when there are no interfaces configured in openresolv.

resolvconf.in Outdated
@@ -444,6 +444,7 @@ list_resolv()
list=
report=false
retval=0
pattern_specified="$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 should appear after the shift above as that's where the parameters to variables assignment happens.
Maybe add some whitespace between the non parameter assignments too.

@hramrach hramrach force-pushed the master branch 2 times, most recently from 5b2d85a to 7d618c2 Compare April 21, 2023 16:02
resolvconf.in Outdated
@@ -523,7 +525,8 @@ list_resolv()
fi

cd "$IFACEDIR"
retval=1
retval=0
[ -n "$pattern_specified" ] && retval=1
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be more clear as to the intent.

Can you change this to somthing like this please?

# Return an error only if we have a pattern to match with no results
if [ -n "pattern_specified" ]; then
     retval=1
else
     retval=0
fi

This also reduces the number of assignments on the more common path of supplying a pattern.

The -i and -l options have an optional pattern argument, and it makes
sense to return an error when the pattern does not match.

However, when no pattern is specified and no interface is configured an
error is returned as well.

This makes it problematic to detect if -i option is supported - an error
is returned both when the option is not supported by other resolvconf
implementation, and when there are no interfaces configured in
openresolv.

Signed-off-by: Michal Suchanek <[email protected]>
@rsmarples rsmarples merged commit b858386 into NetworkConfiguration:master Apr 21, 2023
@rsmarples
Copy link
Member

Thanks for the patch!

rsmarples added a commit that referenced this pull request May 23, 2023
Fixes a regression introduced in #17 which in turn broke the
main operationm of resolvconf.
I should have tested this better.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants