Hacker News new | ask | show | jobs
by mturmon 2048 days ago
This is true, and I agree. But this kind of "language-within-language" problem (regex within sh) comes up a lot when formulating grep and sed command lines.

Come to think of it, I think this is the most frequently-encountered class of "this line didn't do what I thought it would" type errors that I get as a near-daily user of (ba)sh for a few decades now.

Question for the group: When you encounter this kind of issue, e.g. the shell is stealing a single or double quote meant to be in the regex, do you diagnose the problem w/r/t the shell precedence rules for quotes and backslashes, or do you just blindly put the opposite type of quote around the whole thing and re-run?

Because probably half the time I use a basic blind strategy, and that's not usually how I approach programming errors!