hackrf-spectrum-analyzer icon indicating copy to clipboard operation
hackrf-spectrum-analyzer copied to clipboard

Shell script generated with make may have a bug.

Open mocketech opened this issue 6 years ago • 3 comments

Under Ubuntu 18.04LTS environment, I did make command, and it generated the shell script 'build/hackrf_sweep_spectrum_analyzer.sh.' The first line of the script is below.

-e #!/bin/bash

It, however, should be below.

#!/bin/bash or #!/bin/bash -e

I briefly check the makefile. Unfortunately, I did not find why it was generated. Could you check this out?

Thank you.

mocketech avatar Oct 15 '19 12:10 mocketech

This is the line in the makefile. Looks like it should be #!/bin/bash

https://github.com/pavsa/hackrf-spectrum-analyzer/blob/master/src/hackrf-sweep/Makefile#L170

JonMurphy avatar Feb 25 '20 03:02 JonMurphy

-e should enable expandion of \n in the string passed to echo. can you post man echo? It might be not that portable solution. I simply needed to generate multiline script with echo.

pavsa avatar Feb 25 '20 08:02 pavsa

ECHO(1) User Commands ECHO(1)

NAME echo - display a line of text

SYNOPSIS echo [SHORT-OPTION]... [STRING]... echo LONG-OPTION

DESCRIPTION Echo the STRING(s) to standard output.

   -n     do not output the trailing newline

   -e     enable interpretation of backslash escapes

   -E     disable interpretation of backslash escapes (default)

   --help display this help and exit

   --version
          output version information and exit

   If -e is in effect, the following sequences are recognized:

   \\     backslash

   \a     alert (BEL)

   \b     backspace

   \c     produce no further output

   \e     escape

   \f     form feed

   \n     new line

   \r     carriage return

   \t     horizontal tab

   \v     vertical tab

   \0NNN  byte with octal value NNN (1 to 3 digits)

   \xHH   byte with hexadecimal value HH (1 to 2 digits)

   NOTE:  your  shell  may  have its own version of echo, which usually supersedes the version described here.  Please
   refer to your shell's documentation for details about the options it supports.

  PDF of man echo: man.echo.pdf

EDIT: Here is the error I see when running:

$ build/hackrf_sweep_spectrum_analyzer.sh

build/hackrf_sweep_spectrum_analyzer.sh: line 1: -e: command not found
Persistent image set to 320x240
$ cat build/hackrf_sweep_spectrum_analyzer.sh

-e #!/bin/bash
DIRECTORY=`dirname $0`
java -jar $DIRECTORY/lib/hackrf_sweep_spectrum_analyzer.jar

FYI - This works as expected in a command line:

$ echo -e '#!/bin/bash\nDIRECTORY=`dirname $0`\njava -jar $DIRECTORY/lib/hackrf_sweep_spectrum_analyzer.jar' > build/hackrf_sweep_spectrum_analyzer.sh
$
$ cat hackrf_sweep_spectrum_analyzer.sh

#!/bin/bash
DIRECTORY=`dirname $0`
java -jar $DIRECTORY/lib/hackrf_sweep_spectrum_analyzer.jar

So maybe echo -e isn't liked in a makefile (sorry don't know anything about makefiles)

JonMurphy avatar Feb 25 '20 17:02 JonMurphy