All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] color: Fix backslash-escape sequences for some non-bash shells
Date: Wed, 1 Mar 2017 14:13:23 +0100	[thread overview]
Message-ID: <20170301131323.GC32207@rei.lan> (raw)
In-Reply-To: <20170217000345.18704-2-pvorel@suse.cz>

Hi!
> @@ -21,13 +21,13 @@
>   * NOTE: these colors should match colors defined in tst_flag2color() in
>   * testcases/lib/tst_ansi_color.sh
>   */
> -#define ANSI_COLOR_BLUE		"\e[1;34m"
> -#define ANSI_COLOR_GREEN	"\e[1;32m"
> -#define ANSI_COLOR_MAGENTA	"\e[1;35m"
> -#define ANSI_COLOR_RED		"\e[1;31m"
> -#define ANSI_COLOR_YELLOW	"\e[1;33m"
> +#define ANSI_COLOR_BLUE		"\033[34;1m"
> +#define ANSI_COLOR_GREEN	"\033[32;1m"
> +#define ANSI_COLOR_MAGENTA	"\033[35;1m"
> +#define ANSI_COLOR_RED		"\033[31;1m"
> +#define ANSI_COLOR_YELLOW	"\033[33;1m"
>  
> -#define ANSI_COLOR_RESET	"\e[00m"
> +#define ANSI_COLOR_RESET	"\033[0m"

I suppose that we are changing the C header to keep it consistent with
the shell one? I guess that's OK.

>  char* tst_ttype2color(int ttype);
>  int tst_color_enabled(int fd);
> diff --git a/testcases/lib/tst_ansi_color.sh b/testcases/lib/tst_ansi_color.sh
> index 987397144..1fcd7a4c9 100644
> --- a/testcases/lib/tst_ansi_color.sh
> +++ b/testcases/lib/tst_ansi_color.sh
> @@ -21,11 +21,11 @@
>  tst_flag2color()
>  {
>  	# NOTE: these colors should match colors defined in include/tst_ansi_color.h
> -	local ansi_color_blue='\e[1;34m'
> -	local ansi_color_green='\e[1;32m'
> -	local ansi_color_magenta='\e[1;35m'
> -	local ansi_color_red='\e[1;31m'
> -	local ansi_color_yellow='\e[1;33m'
> +	local ansi_color_blue='\033[34;1m'
> +	local ansi_color_green='\033[32;1m'
> +	local ansi_color_magenta='\033[35;1m'
> +	local ansi_color_red='\033[31;1m'
> +	local ansi_color_yellow='\033[33;1m'

I'm a bit puzzled by the change of the position of color and bold in the
escape sequence. As far as I can tell it does not matter at all, or does
it?

And the patch description does not describe this part of the change
either...

>  	case "$1" in
>  	TPASS) printf $ansi_color_green;;
> @@ -52,5 +52,5 @@ tst_print_colored()
>  
>  	[ "$color" = "1" ] && tst_flag2color "$1"
>  	printf "$2"
> -	[ "$color" = "1" ] && printf '\e[00m'
> +	[ "$color" = "1" ] && printf '\033[0m'
>  }
> -- 
> 2.11.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

  parent reply	other threads:[~2017-03-01 13:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17  0:03 [LTP] [PATCH 1/2] color: Rename file Petr Vorel
2017-02-17  0:03 ` [LTP] [PATCH 2/2] color: Fix backslash-escape sequences for some non-bash shells Petr Vorel
2017-02-28 21:28   ` Petr Vorel
2017-03-01 13:13   ` Cyril Hrubis [this message]
2017-03-01 13:36     ` Petr Vorel
2017-03-01 14:03       ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170301131323.GC32207@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.