Crib Notes: Finding Missing Single- Or Double-Quote Pairs
Thomas H Jones II

Thomas H Jones II @ferricoxide

About: Been using UNIX since the late 80s; Linux since the mid-90s; virtualization since the early 2000s and spent the past few years working in the cloud space.

Location:
Alexandria, VA, USA
Joined:
Nov 3, 2017

Crib Notes: Finding Missing Single- Or Double-Quote Pairs

Publish Date: May 13 '20
1 0

So, today, was writing a BASH utility. As per normal, I have a commit-time check that runs it through shellchecker. That test came up green. However, when I ran the script if finished by complaining:

XXXXXX.sh: line 290: unexpected EOF while looking for matching `"'

Naturally, my reaction was something along the lines of:

I mean, shellchecker's usually pretty damned good about finding trivial flubs like that. So, Googled about to see if there was an easy way to double-check things. My search was fruitful – I found this cute, little snippet:

| tr -cd '"\n' | awk 'length%2==1 {print NR, $0}'

I catted my script to that pipe and, for better or worse, it agreed with shellchecker that all my single- and double-quotes were properly paired.

Comments 0 total

    Add comment