LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-29-2024, 08:29 PM   #1
mbradbones
LQ Newbie
 
Registered: Oct 2005
Posts: 6

Rep: Reputation: 0
why does bash not report the line where it is missing a "


My question is why bash does not report against line 2 where I left off the trailing " at the end on purpose to see how it reports this back.

I run a bash script and get this error:
./test: line 4: unexpected EOF while looking for matching `"'

The script:

#!/usr/bin/bash
echo "this is life
echo "now is the time"
echo "have we reached the end"
 
Old 10-29-2024, 09:50 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,274

Rep: Reputation: 6132Reputation: 6132Reputation: 6132Reputation: 6132Reputation: 6132Reputation: 6132Reputation: 6132Reputation: 6132Reputation: 6132Reputation: 6132Reputation: 6132
Code:
str1="This string contains a line
feed"

echo "this is a 
test"
I am not an expert on bash parsing but both lines are valid syntax and neither have having matching quotes on the same line. It would then sort of make sense the parser would error at the end of the file searching for matching quotes.
 
1 members found this post helpful.
Old 10-29-2024, 09:54 PM   #3
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,300
Blog Entries: 6

Rep: Reputation: 1907Reputation: 1907Reputation: 1907Reputation: 1907Reputation: 1907Reputation: 1907Reputation: 1907Reputation: 1907Reputation: 1907Reputation: 1907Reputation: 1907
What are you asking? You left off the end quote so you got an error.

echo statements can span multiple lines.
Code:
echo "These
are multiple
lines"
These
are multiple
lines
This would have worked:
Code:
echo "this is life
echo "now is the time"
echo "have we reached the end""
 
1 members found this post helpful.
Old 10-30-2024, 12:44 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,935
Blog Entries: 1

Rep: Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893
The string literals in the original script:
Code:
this is life\necho 
now
is
the
time\necho 
have
we
reached
the
end<unpaired quote>
 
Old 10-30-2024, 03:17 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,009

Rep: Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627
with other words: bash has no any idea which " is missing (from where). It could be anywhere. What it knows was reported, unexpected EOF while looking for matching `"'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"DWARF error: section .debug_info is larger than its filesize!" when running "perf report" and "stackcollapse-perf.pl" xiaochen Programming 2 05-19-2022 01:09 AM
[SOLVED] (Bourne shell) Why does ". ./myscript" run but ". sh myscript" does not? FireWalkWithMe Linux - Newbie 2 08-07-2015 08:26 AM
Help With Java Problem Please"""""""""""" suemcholan Linux - Newbie 1 04-02-2008 07:02 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 04:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration