diff mbox series

[1/2] docparse/parse.sh: Fix parsing on dash

Message ID 20201217121520.25713-2-pvorel@suse.cz
State Accepted
Headers show
Series Travis build fixes | expand

Commit Message

Petr Vorel Dec. 17, 2020, 12:15 p.m. UTC
bash keeps escape sequences (e.g. \t and \n) when using echo:

$ a="-v\tverbose output\n"; echo "$a"
-v\tverbose output\n
$

But dash interprets them (behaves like echo -e on bash):

$ a="-v\tverbose output\n"; echo -e "$a"
-e -v	verbose output

$

Using printf does not help, because it'd have to be separated with --
which cannot be used for printing variables.
Fortunately cat << EOF redirection is portable.
In the future we should probably avoid shell as much as possible.

Fixes: 0962c9a37 ("syscalls/perf_event_open02: Use anonymous .options")

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 docparse/parse.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Cyril Hrubis Dec. 17, 2020, 12:20 p.m. UTC | #1
Hi!
> bash keeps escape sequences (e.g. \t and \n) when using echo:
> 
> $ a="-v\tverbose output\n"; echo "$a"
> -v\tverbose output\n
> $
> 
> But dash interprets them (behaves like echo -e on bash):
> 
> $ a="-v\tverbose output\n"; echo -e "$a"
> -e -v	verbose output

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

Can we remove the \t from the perf_event_open02.c as well please? I
doubt that it will do any good when we pass the strings into asciidoc
parser...
Petr Vorel Dec. 17, 2020, 12:36 p.m. UTC | #2
> Hi!
> > bash keeps escape sequences (e.g. \t and \n) when using echo:

> > $ a="-v\tverbose output\n"; echo "$a"
> > -v\tverbose output\n
> > $

> > But dash interprets them (behaves like echo -e on bash):

> > $ a="-v\tverbose output\n"; echo -e "$a"
> > -e -v	verbose output

> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Thanks for both reviews!

> Can we remove the \t from the perf_event_open02.c as well please? I
> doubt that it will do any good when we pass the strings into asciidoc
> parser...
Sure, I'll replace it with <tab>.

Kind regards,
Petr
Petr Vorel Dec. 17, 2020, 12:58 p.m. UTC | #3
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

Both patches merged, thanks!

Kind regards,
Petr
diff mbox series

Patch

diff --git a/docparse/parse.sh b/docparse/parse.sh
index 4ae0c42b2..172eab702 100755
--- a/docparse/parse.sh
+++ b/docparse/parse.sh
@@ -32,7 +32,9 @@  for test in `find testcases/ -name '*.c'`; do
 			echo ','
 		fi
 		first=
-		echo -n "$a"
+		cat <<EOF
+$a
+EOF
 	fi
 done