Permalink
Browse files

Fix bug when a bad help topic is passed, and add tests.

e.g. 'help ZZZ'

Also, rename a spec test file so we can put all bash-specific builtins
in it.

Fixes issue #51.
  • Loading branch information...
Andy Chu
Andy Chu committed Nov 16, 2017
1 parent dbc4727 commit ea1d24fd9519fe3bd3f719f3db8e30d4472f3c47
Showing with 18 additions and 5 deletions.
  1. +2 −2 core/builtin.py
  2. +12 −0 spec/{builtin-type.test.sh → builtin-bash.test.sh}
  3. +4 −3 test/spec.sh
View
@@ -864,8 +864,8 @@ def Help(argv, loader):
else:
try:
section_id = osh_help.TOPIC_LOOKUP[topic]
except IndexError:
util.error('No help for topic %r', topic)
except KeyError:
util.error('No help topics match %r', topic)
return 1
else:
try:
@@ -25,3 +25,15 @@ type -t find xargs
type -t echo ZZZ find =
echo status=$?
# stdout-json: "builtin\nfile\nstatus=1\n"
### help
help
help help
# status: 0
### bad help topic
help ZZZ 2>$TMP/err.txt
echo "help=$?"
cat $TMP/err.txt | grep -i 'no help topics' >/dev/null
echo "grep=$?"
# stdout-json: "help=1\ngrep=0\n"
View
@@ -271,9 +271,10 @@ builtin-test() {
${REF_SHELLS[@]} $OSH "$@"
}
# Bash impleement type -t, but no other shell does. For Nix.
builtin-type() {
sh-spec spec/builtin-type.test.sh \
# 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 "$@"
}

0 comments on commit ea1d24f

Please sign in to comment.