Sep-18-2019, 12:16 AM
unlike python, bash does not tell you where you left out a quote or { or }. it just tells you at the end that it hit EOF looking for a matching character. this script (for 3.6 or later) is a quickie i wrote to find just such a problem in a huge bash script i have (i have about 10 of these huge ones that i wish i had time to rewrite into python). yes, i do tend to code like this (one letter variables, etc) for quickies. do not use this as an example of good coding.
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys n = 0 z = "'"+'"{' for l in sys.stdin: n += 1 l = l.strip() if l and l[0]=='#': continue for q in z: if q=='{': if l and l[-1]=='}': continue for x in range(len(l)): s=' '*x l = l.replace('()'+s+'{','()'+s) l = l.replace('}','{') s = l.split(q) if len(s)%2 == 0: print(f'oddetall av {q} i linje {n} ... {l}')
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.