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

Fix kldunload on FreeBSD: show modules with digits in their file names #184

Closed
wants to merge 1 commit into from

Conversation

0mp
Copy link
Contributor

@0mp 0mp commented Jan 18, 2018

There were some issues with the sed implementation of kldunload completions. This is a rewrite, which uses compgen.

It fix the issue with not displaying kernel modules with digits inside their names, which means that previously a loaded kernel module called "i915kms" would never be suggested to the user by Bash completions.

Also, thanks to the replacement of sed with compgen, the user will no longer see errors like "RE error: parentheses not balanced" when requesting completion after typing "kldunload /".


The patch was tested on FreeBSD 12.0-CURRENT. It should not cause any undesired behaviours. I also check related test files but it seemed to be unnecessary to modify them in this case.

There were some issues with the sed implementation of kldunload
completions. This is a rewrite, which uses compgen.

It fix the issue with not displaying kernel modules with digits inside
their names, which means that previously a loaded kernel module called
"i915kms" would never be suggested to the user by Bash completions.

Also, thanks to the replacement of sed with compgen, the user will no
longer see errors like "RE error: parentheses not balanced" when
requesting completion after typing "kldunload /".
Copy link
Owner

@scop scop left a comment

Choose a reason for hiding this comment

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

Thanks. In addition to the one inline comment, it would be really good to have some kind of better test possibilities for this. The only FreeBSD box I have convenient access to just outputs "kernel" from kldstat and my FreeBSD knowledge is very minimal, so there's not much I can say about this.

One very good thing would be to install a mock kldstat command, and to have it output something that is expected on a typical FreeBSD box. There's an example of this for showmount in test/lib/completions/mount.exp and test/fixtures/mount/. Would you be interested in taking a look at making the test suite use an approach like this for kldstat (and other FreeBSD specific commands of course, if you feel like it)?

@@ -7,8 +7,8 @@ _kldunload()
local cur prev words cword
_init_completion || return

COMPREPLY=( $( kldstat | command sed -ne \
"s/^.*[[:blank:]]\{1,\}\($cur[a-z_]\{1,\}\).ko$/\1/p" ) )
COMPREPLY=( $( compgen -W '$(kldstat)' -X 'kernel' -X '!*ko' -- "$cur" ) )
Copy link
Owner

Choose a reason for hiding this comment

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

The !*ko here should probably be !*.ko, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't make any difference but yeah, !*.ko is more robust.

@0mp
Copy link
Contributor Author

0mp commented Jan 21, 2018

Thank you for your response!

Thanks. In addition to the one inline comment, it would be really good to have some kind of better test possibilities for this. The only FreeBSD box I have convenient access to just outputs "kernel" from kldstat and my FreeBSD knowledge is very minimal, so there's not much I can say about this.

Yeah, if kldstat outputs only `kernel on your FreeBSD box then maybe you've got no kernel modules loaded dynamically.

One very good thing would be to install a mock kldstat command, and to have it output something that is expected on a typical FreeBSD box. There's an example of this for showmount in test/lib/completions/mount.exp and test/fixtures/mount/. Would you be interested in taking a look at making the test suite use an approach like this for kldstat (and other FreeBSD specific commands of course, if you feel like it)?

I'll try to send some patches implementing those suggestions. I'll do it for the kldstat and kldunload only for now.

Thank you for your time! 😄

@scop scop closed this in 6f17a85 Jan 22, 2018
@scop
Copy link
Owner

scop commented Jan 22, 2018

Merged with the !*.ko change, please file new pull requests for the test suite improvements when you find time. Thanks in advance!

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.

None yet

2 participants