lmi
[Top][All Lists]
Advanced

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

Re: [lmi] [PATCH] Make test_coding_rules_test.sh a bash script


From: Vadim Zeitlin
Subject: Re: [lmi] [PATCH] Make test_coding_rules_test.sh a bash script
Date: Sat, 16 Jul 2016 01:42:26 +0200

On Fri, 15 Jul 2016 23:16:00 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2016-07-15 21:41, Vadim Zeitlin wrote:
GC> 
GC> [...dash doesn't do ANSI-C quoting here:
GC>   boilerplate="$good_copyright"$'\n'"$good_url"
GC> so you suggested changing the hashbang from 'sh' to 'bash']

 Sorry, this is not the usual plain ANSI C quoting, it's the special ksh93
$'...' syntax, also supported by bash and zsh, but not dash. Dash does
support plain ANSI C escape sequences in its built-in echo and printf just
fine.

GC> I'd rather fix the problem by making the script work with dash.

 OK, then please apply the following patch:
---------------------------------- >8 --------------------------------------
diff --git a/test_coding_rules_test.sh b/test_coding_rules_test.sh
index fc3d445..5f5cc9a 100755
--- a/test_coding_rules_test.sh
+++ b/test_coding_rules_test.sh
@@ -34,7 +34,7 @@ good_copyright="...Copyright (C)...`date -u +'%Y'`..."

 good_url="...http://savannah.nongnu.org/projects/lmi...";

-boilerplate="$good_copyright"$'\n'"$good_url"
+boilerplate=$(printf "$good_copyright\n$good_url")

 # Files in general.

@@ -130,25 +130,25 @@ $boilerplate
 Spaces are permitted; they  can   be    consecutive.
 EOF

-ascii_ff=$'\f'
+ascii_ff=$(printf "\f")
 cat >eraseme_whitespace_001 <<EOF
 $boilerplate
 $ascii_ff
 EOF

-ascii_cr=$'\r'
+ascii_cr=$(printf "\r")
 cat >eraseme_whitespace_002 <<EOF
 $boilerplate
 $ascii_cr
 EOF

-ascii_ht=$'\t'
+ascii_ht=$(printf "\t")
 cat >eraseme_whitespace_003 <<EOF
 $boilerplate
 $ascii_ht
 EOF

-ascii_vt=$'\v'
+ascii_vt=$(printf "\v")
 cat >eraseme_whitespace_004 <<EOF
 $boilerplate
 $ascii_vt
---------------------------------- >8 --------------------------------------

 To the best of my knowledge, this is as portable as it gets because
printf, unlike echo, should behave in the same way everywhere in any shell
less than 20 years old.

GC> If you see no trivial way to make this work portably, then would
GC> you please tell me whether the patch that follows makes it work
GC> correctly with debian? (This patch works with cygwin, but I
GC> regrettably haven't yet moved development to debian.)

 The proposed patch doesn't work because it still uses $'\f' etc, so they
must be changed as done above.

 Regards,
VZ


reply via email to

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