[1/2] gdbsupport: Resolve shellcheck issues in create-version.sh script

Message ID 0784fb919936e8e5afa466c7597c37c574a44bb9.1585311874.git.andrew.burgess@embecosm.com
State New
Headers show
Series
  • Adding git sha information to the version string
Related show

Commit Message

Andrew Burgess March 27, 2020, 12:27 p.m.
Run shellcheck (version 0.4.7) on the create-version.sh script, and
resolve the issues it highlighter - they all seemed reasonable.

gdbsupport/ChangeLog:

	* create-version.sh: Resolve issues highlighted by shellcheck.
---
 gdbsupport/ChangeLog         |  4 ++++
 gdbsupport/create-version.sh | 18 ++++++++++--------
 2 files changed, 14 insertions(+), 8 deletions(-)

-- 
2.14.5

Comments

Simon Marchi March 27, 2020, 1:11 p.m. | #1
On 2020-03-27 8:27 a.m., Andrew Burgess wrote:
> Run shellcheck (version 0.4.7) on the create-version.sh script, and

> resolve the issues it highlighter - they all seemed reasonable.

> 

> gdbsupport/ChangeLog:

> 

> 	* create-version.sh: Resolve issues highlighted by shellcheck.

> ---

>  gdbsupport/ChangeLog         |  4 ++++

>  gdbsupport/create-version.sh | 18 ++++++++++--------

>  2 files changed, 14 insertions(+), 8 deletions(-)

> 

> diff --git a/gdbsupport/create-version.sh b/gdbsupport/create-version.sh

> index 81d6dbf8c1f..6135d219d94 100755

> --- a/gdbsupport/create-version.sh

> +++ b/gdbsupport/create-version.sh

> @@ -27,12 +27,14 @@ host_alias="$2"

>  target_alias="$3"

>  output="$4"

>  

> -rm -f version.c-tmp $output version.tmp

> -date=`sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$/\1/p' $srcdir/../bfd/version.h`

> -sed -e "s/DATE/$date/" < $srcdir/version.in > version.tmp

> -echo '#include "gdbsupport/version.h"' >> version.c-tmp

> -echo 'const char version[] = "'"`sed q version.tmp`"'";' >> version.c-tmp

> -echo 'const char host_name[] = "'"$host_alias"'";' >> version.c-tmp

> -echo 'const char target_name[] = "'"$target_alias"'";' >> version.c-tmp

> -mv version.c-tmp $output

> +rm -f version.c-tmp "$output" version.tmp

> +date=$(sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$/\1/p' "$srcdir/../bfd/version.h")

> +sed -e "s/DATE/$date/" < "$srcdir/version.in" > version.tmp

> +{

> +    echo '#include "gdbsupport/version.h"'

> +    echo 'const char version[] = "'"$(sed q version.tmp)"'";'

> +    echo 'const char host_name[] = "'"$host_alias"'";'

> +    echo 'const char target_name[] = "'"$target_alias"'";'

> +} >> version.c-tmp

> +mv version.c-tmp "$output"

>  rm -f version.tmp

> -- 

> 2.14.5

> 


Thanks, I think it's probably worth pushing this patch right away, it's an improvement
in its own right.

Simno
Andrew Burgess March 27, 2020, 1:57 p.m. | #2
* Simon Marchi <simark@simark.ca> [2020-03-27 09:11:33 -0400]:

> On 2020-03-27 8:27 a.m., Andrew Burgess wrote:

> > Run shellcheck (version 0.4.7) on the create-version.sh script, and

> > resolve the issues it highlighter - they all seemed reasonable.

> > 

> > gdbsupport/ChangeLog:

> > 

> > 	* create-version.sh: Resolve issues highlighted by shellcheck.

> > ---

> >  gdbsupport/ChangeLog         |  4 ++++

> >  gdbsupport/create-version.sh | 18 ++++++++++--------

> >  2 files changed, 14 insertions(+), 8 deletions(-)

> > 

> > diff --git a/gdbsupport/create-version.sh b/gdbsupport/create-version.sh

> > index 81d6dbf8c1f..6135d219d94 100755

> > --- a/gdbsupport/create-version.sh

> > +++ b/gdbsupport/create-version.sh

> > @@ -27,12 +27,14 @@ host_alias="$2"

> >  target_alias="$3"

> >  output="$4"

> >  

> > -rm -f version.c-tmp $output version.tmp

> > -date=`sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$/\1/p' $srcdir/../bfd/version.h`

> > -sed -e "s/DATE/$date/" < $srcdir/version.in > version.tmp

> > -echo '#include "gdbsupport/version.h"' >> version.c-tmp

> > -echo 'const char version[] = "'"`sed q version.tmp`"'";' >> version.c-tmp

> > -echo 'const char host_name[] = "'"$host_alias"'";' >> version.c-tmp

> > -echo 'const char target_name[] = "'"$target_alias"'";' >> version.c-tmp

> > -mv version.c-tmp $output

> > +rm -f version.c-tmp "$output" version.tmp

> > +date=$(sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$/\1/p' "$srcdir/../bfd/version.h")

> > +sed -e "s/DATE/$date/" < "$srcdir/version.in" > version.tmp

> > +{

> > +    echo '#include "gdbsupport/version.h"'

> > +    echo 'const char version[] = "'"$(sed q version.tmp)"'";'

> > +    echo 'const char host_name[] = "'"$host_alias"'";'

> > +    echo 'const char target_name[] = "'"$target_alias"'";'

> > +} >> version.c-tmp

> > +mv version.c-tmp "$output"

> >  rm -f version.tmp

> > -- 

> > 2.14.5

> > 

> 

> Thanks, I think it's probably worth pushing this patch right away, it's an improvement

> in its own right.


Thanks.  I went ahead and pushed this.

Andrew

Patch

diff --git a/gdbsupport/create-version.sh b/gdbsupport/create-version.sh
index 81d6dbf8c1f..6135d219d94 100755
--- a/gdbsupport/create-version.sh
+++ b/gdbsupport/create-version.sh
@@ -27,12 +27,14 @@  host_alias="$2"
 target_alias="$3"
 output="$4"
 
-rm -f version.c-tmp $output version.tmp
-date=`sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$/\1/p' $srcdir/../bfd/version.h`
-sed -e "s/DATE/$date/" < $srcdir/version.in > version.tmp
-echo '#include "gdbsupport/version.h"' >> version.c-tmp
-echo 'const char version[] = "'"`sed q version.tmp`"'";' >> version.c-tmp
-echo 'const char host_name[] = "'"$host_alias"'";' >> version.c-tmp
-echo 'const char target_name[] = "'"$target_alias"'";' >> version.c-tmp
-mv version.c-tmp $output
+rm -f version.c-tmp "$output" version.tmp
+date=$(sed -n -e 's/^.* BFD_VERSION_DATE \(.*\)$/\1/p' "$srcdir/../bfd/version.h")
+sed -e "s/DATE/$date/" < "$srcdir/version.in" > version.tmp
+{
+    echo '#include "gdbsupport/version.h"'
+    echo 'const char version[] = "'"$(sed q version.tmp)"'";'
+    echo 'const char host_name[] = "'"$host_alias"'";'
+    echo 'const char target_name[] = "'"$target_alias"'";'
+} >> version.c-tmp
+mv version.c-tmp "$output"
 rm -f version.tmp