Skip to content

Commit

Permalink
[builtin/printf] Fix crash when no arguments are passed.
Browse files Browse the repository at this point in the history
Addresses issue #404.
  • Loading branch information
Andy Chu committed Jul 7, 2019
1 parent 9f0efb6 commit a39bfe3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ def ReadRequired(self, error_msg):
return arg

def ReadRequired2(self, error_msg):
spid = self.spids[self.i]
try:
arg = self.Peek()
except IndexError:
# point at argv[0]
raise UsageError(error_msg, span_id=self._FirstSpanId())
spid = self.spids[self.i]
self.Next()
return arg, spid

Expand Down
6 changes: 6 additions & 0 deletions spec/builtin-printf.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
#
# I suppose it is technically correct, but it looks very ugly.

#### printf with no args
printf
## status: 2
## OK dash/mksh/zsh status: 1
## stdout-json: ""

#### printf -v %s
var=foo
printf -v $var %s 'hello there'
Expand Down

0 comments on commit a39bfe3

Please sign in to comment.