Permalink
Browse files

Rename compgen test for consistency.

Use args.UsageError more consistently through core/builtin.py.

All spec tests pass.
  • Loading branch information...
Andy Chu
Andy Chu committed Sep 4, 2018
1 parent 29de900 commit d16aabf28dbeb41310e0de8654e2c89d436852af
Showing with 20 additions and 18 deletions.
  1. +5 −8 core/builtin.py
  2. +6 −1 spec/{compgen.test.sh → builtin-compgen.test.sh}
  3. +2 −2 spec/builtin-trap.test.sh
  4. +7 −7 test/spec.sh
View
@@ -806,12 +806,11 @@ def CompGen(argv, funcs):
status = 0
if arg.A:
if arg.A != 'function':
status = 1
raise args.UsageError('compgen: %s: invalid action name' % arg.A)
else:
if arg.A == 'function':
for func_name in sorted(funcs):
print(func_name)
else:
raise args.UsageError('compgen: %s: invalid action name' % arg.A)
else:
util.warn('*** command without -A not implemented ***')
status = 1
@@ -1023,8 +1022,7 @@ def Alias(argv, aliases):
def UnAlias(argv, aliases):
if not argv:
util.usage('unalias NAME...')
return 2
raise args.UsageError('unalias NAME...')
status = 0
for name in argv:
@@ -1149,8 +1147,7 @@ def Trap(argv, traps, nodes_to_run, ex):
code_str = argv[0]
sig_spec = argv[1]
except IndexError:
util.usage('trap CODE SIGNAL_SPEC')
return 1
raise args.UsageError('trap CODE SIGNAL_SPEC')
# NOTE: sig_spec isn't validated when removing handlers.
if code_str == '-':
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#### Print function list
#### -A function prints functions
add () { expr 4 + 4; }
div () { expr 6 / 2; }
ek () { echo hello; }
@@ -15,3 +15,8 @@ add
div
ek
## END
#### Invalid syntax
compgen -A foo
echo status=$?
## stdout: status=2
@@ -36,8 +36,8 @@ echo $?
#### Invalid trap invocation
trap 'foo'
echo status=$?
## stdout: status=1
## OK bash stdout: status=2
## stdout: status=2
## OK dash stdout: status=1
## BUG mksh stdout: status=0
#### exit 1 when trap code string is invalid
View
@@ -232,7 +232,7 @@ blog-other1() {
}
alias() {
sh-spec spec/alias.test.sh --osh-failures-allowed 20 \
sh-spec spec/alias.test.sh --osh-failures-allowed 22 \
${REF_SHELLS[@]} $ZSH $OSH_LIST "$@"
}
@@ -333,8 +333,12 @@ builtin-trap() {
# Bash implements type -t, but no other shell does. For Nix.
# zsh/mksh/dash don't have the 'help' builtin.
builtin-bash() {
sh-spec spec/builtin-bash.test.sh \
$BASH $OSH_LIST "$@"
sh-spec spec/builtin-bash.test.sh $BASH $OSH_LIST "$@"
}
# This is bash/OSH only
builtin-compgen() {
sh-spec spec/builtin-compgen.test.sh $BASH $OSH_LIST "$@"
}
builtins-special() {
@@ -583,8 +587,4 @@ shell-grammar() {
sh-spec spec/shell-grammar.test.sh $BASH $MKSH $ZSH "$@"
}
compgen() {
sh-spec spec/compgen.test.sh $BASH $OSH_LIST "$@"
}
"$@"

0 comments on commit d16aabf

Please sign in to comment.