[Bash-completion-devel] [bash-completion-Bugs][312306] chown test "crashes" on FreeBSD (no "root" group)
bash-completion-bugs at alioth.debian.org
bash-completion-bugs at alioth.debian.org
Fri Feb 5 20:45:19 UTC 2010
Bugs item #312306, was changed at 2010-01-30 11:38 by Ville Skyttä
You can respond by visiting:
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312306&group_id=100114
Status: Open
Priority: 2
Submitted By: Ville Skyttä (scop-guest)
Assigned to: Leonard Crestez (cdleonard-guest)
>Summary: chown test "crashes" on FreeBSD (no "root" group)
Distribution: None
Originally reported in: None
Milestone: None
Status: None
Original bug number:
Initial Comment:
FreeBSD does not have a "root" group which I guess is the reason for this "crash":
Running ./completion/chown.exp ...
ERROR: tcl error sourcing ./completion/chown.exp.
ERROR: 0
child process exited abnormally
while executing
"exec bash -c "compgen -A group $partgroup" | wc -l"
(file "lib/completions/chown.exp" line 3)
invoked from within
"if {[assert_bash_type chown]} {
source "lib/completions/chown.exp"
}"
(file "./completion/chown.exp" line 1)
invoked from within
"source ./completion/chown.exp"
("uplevel" body line 1)
invoked from within
"uplevel #0 source ./completion/chown.exp"
invoked from within
"catch "uplevel #0 source $test_file_name""
I wonder if we should make this test system dependent (blindly use for example the "wheel" group on FreeBSD, maybe other *BSD) or use root's primary group as the test group (id -gn root) or loop through a list of group names until one is found (for example root, wheel, other) and use that for the tests or something else...
----------------------------------------------------------------------
>Comment By: Ville Skyttä (scop-guest)
Date: 2010-02-05 22:45
Message:
That appears to fix it, thanks.
----------------------------------------------------------------------
Comment By: Leonard Crestez (cdleonard-guest)
Date: 2010-02-04 15:29
Message:
Proper fix in the find-unique-completion-pair branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=bash-completion/bash-completion.git;a=log;h=refs/heads/find-unique-completion-pair
The function to find an "unambigous completion pair" is large and does character-level string manipulation. It's larger than the chown test itself; but it might be useful for other tests too.
There's also a test for this function so I'm reasonably certain it's correct. The test is in test/unit even if it does not actually test a bash function. It doesn't even need expect; all it tests is tcl code in library.exp. I placed it alongside other unit tests because I didn't want to invent a new category.
----------------------------------------------------------------------
Comment By: Ville Skyttä (scop-guest)
Date: 2010-02-01 21:40
Message:
Applied, thanks. I'll leave this bug open as a reminder for a more elegant fix.
----------------------------------------------------------------------
Comment By: Leonard Crestez (cdleonard-guest)
Date: 2010-01-31 00:22
Message:
The code was intended to just skip the tests if user/groups don't match. However it seems that compgen -A user returns 1 when nothing is found and causes TCL's exec to throw an exception. A quick fix is to just ignore that error code.
A better fix would be list all users or groups on the system and write a function to find an "unambiguous completion pair". Such a function might even be useful in other tests.
Here's the quick fix:
diff --git a/test/lib/completions/chown.exp b/test/lib/completions/chown.exp
index cc56149..480f674 100644
--- a/test/lib/completions/chown.exp
+++ b/test/lib/completions/chown.exp
@@ -24,10 +24,14 @@ set partgroup "roo"
# Skip tests if root:root not available or if roo:roo matches multiple
# users/groups
-if {[exec bash -c "compgen -A user $partuser" | wc -l] > 1 ||
- [exec bash -c "compgen -A user $fulluser" | wc -l] != 1 ||
- [exec bash -c "compgen -A group $partgroup" | wc -l] > 1 ||
- [exec bash -c "compgen -A group $fullgroup" | wc -l] != 1} {
+#
+# compgen -A is used because it's a bash builtin and available everywhere.
+# The || true part prevents exec from throwing an exception if nothing is
+# found.
+if {[exec bash -c "compgen -A user $partuser || true" | wc -l] > 1 ||
+ [exec bash -c "compgen -A user $fulluser || true" | wc -l] != 1 ||
+ [exec bash -c "compgen -A group $partgroup || true" | wc -l] > 1 ||
+ [exec bash -c "compgen -A group $fullgroup || true" | wc -l] != 1} {
untested "Not running complex chown tests."
} else {
assert_complete $fulluser "chown $partuser"
----------------------------------------------------------------------
You can respond by visiting:
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312306&group_id=100114
More information about the Bash-completion-devel
mailing list