Skip to contentSkip to conversation

clean up echo -e usage

PATCH Superseded Max Filippov 3 participants 8 messages Aug 22, 2013 – Aug 26, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Max Filippov

author maintainer
#0 lore raw

cover clean up echo -e usage

This series cleans up non-portable 'echo -e' usage.
I haven't replaced all instances of 'echo -e' though:
- those under Documentation don't affect build;
- those that invoke echo by full path (/bin/echo) probably know what they do;
- those that output user help don't affect build.

Max Filippov (3):
xtensa: don't use echo -e needlessly
x86: don't use echo -e needlessly
raid6/test: replace echo -e with printf

 arch/x86/Makefile         |    2 +-
 arch/xtensa/Makefile      |    4 ++--
 arch/xtensa/boot/Makefile |    2 +-
 lib/raid6/test/Makefile   |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.7.6
author maintainer
#1 lore raw

PATCH 1/3 xtensa: don't use echo -e needlessly

-e is not needed to output strings without escape sequences. This breaks big endian FSF build when the shell is dash, because its builtin echo doesn't understand '-e' switch and outputs it in the echoed string.

---
 arch/xtensa/Makefile      |    4 ++--
 arch/xtensa/boot/Makefile |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/xtensa/Makefile +2 -2
index 136224b..81250ec 100644
@@ -55,10 +55,10 @@ ifneq ($(CONFIG_LD_NO_RELAX),)
 LDFLAGS := --no-relax
 endif
 
-ifeq ($(shell echo -e __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1)
+ifeq ($(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1)
 CHECKFLAGS += -D__XTENSA_EB__
 endif
-ifeq ($(shell echo -e __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1)
+ifeq ($(shell echo __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1)
 CHECKFLAGS += -D__XTENSA_EL__
 endif
 
arch/xtensa/boot/Makefile +1 -1
index 64ffc4b..ca20a89 100644
@@ -12,7 +12,7 @@
 KBUILD_CFLAGS	+= -fno-builtin -Iarch/$(ARCH)/boot/include
 HOSTFLAGS	+= -Iarch/$(ARCH)/boot/include
 
-BIG_ENDIAN	:= $(shell echo -e __XTENSA_EB__ | $(CC) -E - | grep -v "\#")
+BIG_ENDIAN	:= $(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#")
 
 export ccflags-y
 export BIG_ENDIAN
Signature · 1 line
1.7.7.6
author maintainer
#2 lore raw

PATCH 2/3 x86: don't use echo -e needlessly

In reply to Max Filippov

-e is not needed to output strings without escape sequences.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/Makefile +1 -1
index 07639c6..7386e8a 100644
@@ -95,7 +95,7 @@ endif
 
 ifdef CONFIG_X86_X32
 	x32_ld_ok := $(call try-run,\
-			/bin/echo -e '1: .quad 1b' | \
+			/bin/echo '1: .quad 1b' | \
 			$(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
 			$(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMPO" && \
 			$(LD) -m elf32_x86_64 "$$TMPO" -o "$$TMP",y,n)
Signature · 1 line
1.7.7.6
#3 lore raw

Re: [PATCH 2/3] x86: don't use echo -e needlessly

Can we drop the /bin/?

Quoted 24 lines · Max Filippov

-e is not needed to output strings without escape sequences.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>

---
arch/x86/Makefile | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/Makefile +0 -0
index 07639c6..7386e8a 100644
@@ -95,7 +95,7 @@ endif
 

ifdef CONFIG_X86_X32

	x32_ld_ok := $(call try-run,\
arch/x86/Makefile +1 -1
-			/bin/echo -e '1: .quad 1b' | \
+			/bin/echo '1: .quad 1b' | \
			$(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
			$(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMPO" && \
			$(LD) -m elf32_x86_64 "$$TMPO" -o "$$TMP",y,n)
Signature · 1 line
Sent from my mobile phone. Please excuse brevity and lack of formatting.
author maintainer
#4 lore raw

Re: [PATCH 2/3] x86: don't use echo -e needlessly

Quoted 1 line · H. Peter Anvin

Can we drop the /bin/?

Sure.

Quoted 25 lines
Quoted 24 lines · Max Filippov

-e is not needed to output strings without escape sequences.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>

---
arch/x86/Makefile | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/Makefile +0 -0
index 07639c6..7386e8a 100644
@@ -95,7 +95,7 @@ endif
 

ifdef CONFIG_X86_X32

      x32_ld_ok := $(call try-run,\
arch/x86/Makefile +1 -1
-                      /bin/echo -e '1: .quad 1b' | \
+                      /bin/echo '1: .quad 1b' | \
                      $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
                      $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMPO" && \
                      $(LD) -m elf32_x86_64 "$$TMPO" -o "$$TMP",y,n)
Signature · 2 lines
Thanks.
-- Max
author maintainer
#5 lore raw

PATCH 3/3 raid6/test: replace echo -e with printf

In reply to Max Filippov

-e is a non-standard echo option, echo output is implementation-dependent when it is used. Replace echo -e with printf as suggested by POSIX echo manual.

Cc NeilBrown <[email protected]>
Cc Jim Kukunas <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Yuanhan Liu <[email protected]>
---
 lib/raid6/test/Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/raid6/test/Makefile +1 -1
index 087332d..73b0151 100644
@@ -28,7 +28,7 @@ ifeq ($(IS_X86),yes)
                     gcc -c -x assembler - >&/dev/null &&	\
                     rm ./-.o && echo -DCONFIG_AS_AVX2=1)
 else
-        HAS_ALTIVEC := $(shell echo -e '\#include <altivec.h>\nvector int a;' |\
+        HAS_ALTIVEC := $(shell printf '\#include <altivec.h>\nvector int a;\n' |\
                          gcc -c -x c - >&/dev/null && \
                          rm ./-.o && echo yes)
         ifeq ($(HAS_ALTIVEC),yes)
Signature · 1 line
1.7.7.6
reviewer Acked-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] raid6/test: replace echo -e with printf

Quoted 29 lines · Max Filippov

-e is a non-standard echo option, echo output is implementation-dependent when it is used. Replace echo -e with printf as
suggested by POSIX echo manual.

Cc NeilBrown <[email protected]>
Cc Jim Kukunas <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Yuanhan Liu <[email protected]>

---
lib/raid6/test/Makefile | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
lib/raid6/test/Makefile +0 -0
index 087332d..73b0151 100644
@@ -28,7 +28,7 @@ ifeq ($(IS_X86),yes)
                    gcc -c -x assembler - >&/dev/null &&	\
                    rm ./-.o && echo -DCONFIG_AS_AVX2=1)

else
- HAS_ALTIVEC := $(shell echo -e '\#include <altivec.h>\nvector
int a;' |\
+ HAS_ALTIVEC := $(shell printf '\#include <altivec.h>\nvector

int a;\n' |\
                         gcc -c -x c - >&/dev/null && \
                         rm ./-.o && echo yes)
        ifeq ($(HAS_ALTIVEC),yes)
Signature · 1 line
Sent from my mobile phone. Please excuse brevity and lack of formatting.
#7 lore raw

Re: [PATCH 3/3] raid6/test: replace echo -e with printf

Quoted 1 line · On Thu, 22 Aug 2013 17:09:11 +0200 "H. Peter Anvin" <[email protected]> wrote:

Applied with the Ack - thanks.

NeilBrown

Quoted 32 lines
Quoted 29 lines · Max Filippov

-e is a non-standard echo option, echo output is implementation-dependent when it is used. Replace echo -e with printf as
suggested by POSIX echo manual.

Cc NeilBrown <[email protected]>
Cc Jim Kukunas <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Yuanhan Liu <[email protected]>

---
lib/raid6/test/Makefile | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
lib/raid6/test/Makefile +0 -0
index 087332d..73b0151 100644
@@ -28,7 +28,7 @@ ifeq ($(IS_X86),yes)
                    gcc -c -x assembler - >&/dev/null &&	\
                    rm ./-.o && echo -DCONFIG_AS_AVX2=1)

else
- HAS_ALTIVEC := $(shell echo -e '\#include <altivec.h>\nvector
int a;' |\
+ HAS_ALTIVEC := $(shell printf '\#include <altivec.h>\nvector

int a;\n' |\
                         gcc -c -x c - >&/dev/null && \
                         rm ./-.o && echo yes)
        ifeq ($(HAS_ALTIVEC),yes)