bash error tip `"' -> {

Technical issues/questions of an intermediate or advanced nature.
User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

bash error tip `"' -> {

Post#1 by Ed_P » 19 Nov 2023, 03:22

If you run a script you've tweaked and get this:

Code: Select all

guest@porteus:~$ ./mkmods/mkmod50nemobkmks.sh
./mkmods/mkmod50nemobkmks.sh: line 82: unexpected EOF while looking for matching `"'
./mkmods/mkmod50nemobkmks.sh: line 114: syntax error: unexpected end of file
guest@porteus:~$ 
Don't waste time looking for `"' or each character individually. The fix was replacing "${DRV" with "$DRV" on line 12. :shock:

It took me 2 hrs to find the fix. A dumb copy & paste error. :wall:

A more useful error message would have been:

Code: Select all

./mkmods/mkmod50nemobkmks.sh: line 82: unexpected EOF while looking for matching }
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

bash error tip `"' -> {

Post#2 by Rava » 26 Nov 2023, 05:13

From man bash
Have you tried

Code: Select all

       --debugger
              Arrange for the debugger profile to be executed before the shell
              starts.  Turns on extended debugging mode (see  the  description
              of the extdebug option to the shopt builtin below).
and/or

Code: Select all

xtrace  Same as -x.
?
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

bash error tip `"' -> {

Post#3 by Ed_P » 26 Nov 2023, 07:00

Rava wrote:
26 Nov 2023, 05:13
Have you tried

Code: Select all

       --debugger
No. Don't know where to put it in a script.
Rava wrote:
26 Nov 2023, 05:13
and/or

Code: Select all

xtrace  Same as -x.
No. Don't know where to put it in a script.

To debug I use:

Code: Select all

set -x;
:)
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

bash error tip `"' -> {

Post#4 by Rava » 26 Nov 2023, 14:59

set -x is a good start.
And welcome to coding hell when it comes to bugs in your code. The error output is often not that specific.
But that is where either your own knowledge and coding skills kick in. Or a specialised forum like Stack Overflow where there are folks much more knowledgable than you and me put together pointing out the errors of our way :D error(s) in our code. :)
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

bash error tip `"' -> {

Post#5 by Ed_P » 26 Nov 2023, 16:00

:) :happy62: :friends:
Ed

Post Reply