mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Refactor the new 'times' builtin; zero-pad seconds (re: 65d363fd
)
The output format is now identical to mksh's except for
the locale-dependent radix point ('.' or ',').
src/cmd/ksh93/bltins/misc.c:
- Output format tweak: pad seconds with initial zero if < 10.
- Use "too many operands" (e_toomanyops) error msg from 3ba4900e
if there are operands, instead of "bad syntax" (e_badsyntax).
- Consolidate repetitive calculating and printing code
into print_times().
- Get rid of some excessive variables.
src/cmd/ksh93/tests/builtins.sh:
- Update regression tests to match the above.
src/cmd/ksh93/data/builtins.c:
- Update sh_opttimes[] version string.
This commit is contained in:
parent
57ff4676eb
commit
5c677a4c6c
3 changed files with 22 additions and 43 deletions
|
@ -671,11 +671,11 @@ fi
|
|||
# ======
|
||||
# 'times' builtin
|
||||
|
||||
expect=$'0m0.0[0-9]s 0m0.0[0-9]s\n0m0.00s 0m0.00s'
|
||||
expect=$'0m00.0[0-9]s 0m00.0[0-9]s\n0m00.00s 0m00.00s'
|
||||
actual=$("$SHELL" -c times)
|
||||
[[ $actual == $expect ]] || err_exit "times output: expected $(printf %q "$expect"), got $(printf %q "$actual"))"
|
||||
|
||||
expect=$'*: times: incorrect syntax'
|
||||
expect=$'*: times: too many operands'
|
||||
actual=$(set +x; eval 'times Extra Args' 2>&1)
|
||||
[[ $actual == $expect ]] || err_exit "times with args: expected $(printf %q "$expect"), got $(printf %q "$actual"))"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue