bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: remove all unportable uses of echo


From: Jim Meyering
Subject: [PATCH] tests: remove all unportable uses of echo
Date: Thu, 01 Apr 2010 12:17:31 +0200

FYI,

>From 71cd04041fc53d0cc53653d78427996f9e8baa49 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 1 Apr 2010 12:17:09 +0200
Subject: [PATCH] tests: remove all unportable uses of echo

* src/main.c: Use printf rather than echo -ne in a comment.
* tests/fedora: Use printf (not echo) also in ok/fail functions.
* cfg.mk (sc_prohibit_echo_minus_en): New rule, to prohibit
any future introduction.
---
 cfg.mk       |    5 +++++
 src/main.c   |    2 +-
 tests/fedora |    4 ++--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 5e4a890..a392797 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -42,6 +42,11 @@ sc_prohibit_jm_in_m4:
            { echo '$(ME): do not use jm_ in m4 macro names'            \
              1>&2; exit 1; } || :

+sc_prohibit_echo_minus_en:
+       @re='\<echo -[en]'                                              \
+       msg='do not use echo ''-e or echo ''-n; use printf instead'     \
+         $(_prohibit_regexp)
+
 update-copyright-env = \
   UPDATE_COPYRIGHT_USE_INTERVALS=1 \
   UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
diff --git a/src/main.c b/src/main.c
index 8c9e776..0bb4098 100644
--- a/src/main.c
+++ b/src/main.c
@@ -158,7 +158,7 @@ static const char *context_line_color  = "";        /* 
default color pair */
            of 1 ("\33[I"), i.e., it performs pure movement to the next
            tab stop, without any clearing of either content or screen
            attributes (including background color); try
-              echo -ne 'asdfqwerzxcv\rASDF\tZXCV\n'
+              printf 'asdfqwerzxcv\rASDF\tZXCV\n'
            in a bash(1) shell to demonstrate this.  This is not what the
            user would instinctively expect of HT (but is ok for CHT).
            The instinctive behavior would include clearing the terminal
diff --git a/tests/fedora b/tests/fedora
index 20c0dc1..336d913 100644
--- a/tests/fedora
+++ b/tests/fedora
@@ -15,8 +15,8 @@ then
        D='\033[0m'
 fi

-ok ()  { echo -e "${G}OK${D}"; }
-fail () { echo -e "${R}FAIL${D} (See ${U})"; failures=1; }
+ok ()  { printf "${G}OK${D}"; }
+fail () { printf "${R}FAIL${D} (See ${U})"; failures=1; }

 U=https://bugzilla.redhat.com/show_bug.cgi?id=116909
 printf "fgrep false negatives: "
--
1.7.0.3.513.gc8ed0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]