Messages in this thread | | | Date | Fri, 22 Feb 2019 09:29:56 +0900 | From | Masami Hiramatsu <> | Subject | Re: [PATCH] selftests/ftrace: Make the coloring POSIX compliant |
| |
Hi Juerg,
On Wed, 20 Feb 2019 17:13:33 +0100 Juerg Haefliger <juerg.haefliger@canonical.com> wrote:
> echo -e and \e are not POSIX. Depending on what /bin/sh is, we can get > incorrect output like: > $ -e -n [1] Basic trace file check > $ -e [PASS] > > Fix that by using \033 instead of \e and printf.
OK, as far as I can check with checkbashisms, echo -e is not acceptable.
$ checkbashisms ./ftracetest possible bashism in ./ftracetest line 176 (echo -e): echo -e "$@" possible bashism in ./ftracetest line 177 (echo -e): [ "$LOG_FILE" ] && echo -e "$@" | strip_esc >> $LOG_FILE
So it should be fixed, even other shells support it. (Or, update checkbashisms command...)
However,
> prlog() { # messages > - echo -e "$@" > - [ "$LOG_FILE" ] && echo -e "$@" | strip_esc >> $LOG_FILE > + newline="\n" > + if [ "$1" = "-n" ] ; then > + newline= > + shift > + fi > + printf "$@$newline" > + [ "$LOG_FILE" ] && printf "$@$newline" | strip_esc >> $LOG_FILE
This doesn't work when prlog gets several arguments. (like the summary line) for example I got below result.
# of passed: # of failed: # of unresolved: # of untested: # of unsupported: # of xfailed: # of undefined(test bug):
Replacing $@ with $* shows correct result. Could you fix it?
Thank you,
-- Masami Hiramatsu <mhiramat@kernel.org>
| |