request

classic Classic list List threaded Threaded
3 messages Options
t
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

request

t


1. Missing quotes

#========================================
[me@linuxbox me]$ ./trouble.bash
./trouble.bash: line 8430: unexpected EOF while looking for matching "
./trouble.bash: line 8440 systax error: unexpected end of file
#========================================

We have 2017, please add suggestions for errors

For example for "
#===========================
VAR=$(cat file | sed 's/[^"]//g' | awk '{ print length }' | cat -n | grep "[13579]$" |  awk '{print $1}')

echo "We suggest check $VAR"
echo "because this lines of file, contain an odd number of quotes "
#===========================

2. Please hide e-mail for google bots, or remove this e-mail after read.
Thanks !    :-)

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: request

Greg Wooledge
On Fri, Jul 14, 2017 at 11:09:25AM +0200, t wrote:
> #========================================
> [me@linuxbox me]$ ./trouble.bash
> ./trouble.bash: line 8430: unexpected EOF while looking for matching "
> ./trouble.bash: line 8440 systax error: unexpected end of file

Your problem is that your script is about 8300 lines longer than it
should be.  Writing a bash script that's over ~100 lines is crazy.

Yours is over 8000 lines.

I have no words.

> echo "We suggest check $VAR"
> echo "because this lines of file, contain an odd number of quotes "

But lines are explicitly *allowed* to contain an odd number of quotes.
This is how multi-line string constants are created.

body="This is the body of an email.  It has
multiple lines.  There are so many words
that they don't all fit on one line."

When the parser encouters a syntax error, it *cannot* know where the real
problem is; only that there *is* one, somewhere.  You as the programmer
have to be the one to track it down and fix it.

You know that the syntax error originates somewhere *on* or *before*
the line number where the parser hit the brick wall and stopped.  That's
all you know.  You don't know whether it's actually a missing quote.
It could be a missing } or a missing fi or a missing esac or a missing
done, or ANY OTHER missing or incorrect syntax element.

That is *one* of the reasons why bash scripts should be kept small.

> 2. Please hide e-mail for google bots, or remove this e-mail after read.

Screw you.  (And yes, this is the sanitized version.)

t
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: request

t
In reply to this post by t

[quote=Greg]
> You don't know whether it's actually a missing quote.
[/quote]

[quote=t]
There was missing quote. Usually it is correct info from error
and it can tell also what character.
I'm not a professional programmer, but I think that,
Bash only checks the number of quotes ( for bash )
 and ignore commands with regular expressions.
( maybe grep, sed , awk )
This is a very quick method to check, but it can not accurately check.
And that is the reason
 why it does not know where to look.
The rules of programming are very determined, so exist ways to debug.
I do not ask you to fix this, because build debugger it is not easy.
This is the reason why I wrote only "add suggestion".

I do not know, You can write on the blog or other website ...
And people will write all the terms.
( for sed , awk , grep and other command when single quotes can be ignored )
In future this terms can be used for debug,
first in $() , later everything outside.



[quote=Greg]
> It could be a missing } or a missing fi or a missing esac or a missing
> done, or ANY OTHER missing or incorrect syntax element.
[/quote]

[quote=t]
Not, because for missing "fi"  is other error and also
this is not very accurate, but it can point to a broken function.
Poor comfort, but better than nothing.
[quote]

====================================================================={
On Fri, 14 Jul 2017 09:38:03 -0400
Greg Wooledge <[hidden email]> wrote:

> On Fri, Jul 14, 2017 at 11:09:25AM +0200, t wrote:
> > #========================================
> > [me@linuxbox me]$ ./trouble.bash
> > ./trouble.bash: line 8430: unexpected EOF while looking for matching "
> > ./trouble.bash: line 8440 systax error: unexpected end of file
>
> Your problem is that your script is about 8300 lines longer than it
> should be.  Writing a bash script that's over ~100 lines is crazy.
>
> Yours is over 8000 lines.
>
> I have no words.
>
> > echo "We suggest check $VAR"
> > echo "because this lines of file, contain an odd number of quotes "
>
> But lines are explicitly *allowed* to contain an odd number of quotes.
> This is how multi-line string constants are created.
>
> body="This is the body of an email.  It has
> multiple lines.  There are so many words
> that they don't all fit on one line."
>
> When the parser encouters a syntax error, it *cannot* know where the real
> problem is; only that there *is* one, somewhere.  You as the programmer
> have to be the one to track it down and fix it.
>
> You know that the syntax error originates somewhere *on* or *before*
> the line number where the parser hit the brick wall and stopped.  That's
> all you know.  You don't know whether it's actually a missing quote.
> It could be a missing } or a missing fi or a missing esac or a missing
> done, or ANY OTHER missing or incorrect syntax element.
>
> That is *one* of the reasons why bash scripts should be kept small.
>
> > 2. Please hide e-mail for google bots, or remove this e-mail after read.
>
> Screw you.  (And yes, this is the sanitized version.)
>


--
========================================================================================}

Loading...