Hello, On Thu, 22 Sep 2011, Per Jessen wrote:
David Haller wrote:
Inside '' you only need to escape ' itself, which doesn't work, as \ has no special meaning either inside of ''. Workaround: 'foo'"'"'bar' or 'foo'\''bar'
Inside "" you have to IIRC escape !"()`` and $ (the ! only if you've enabled history substitution (set -H).
With sed, I always need to escape +() inside '' to get them to work. Am I doing something wrong?
Depends on what meaning you want the +() to have. Read 'man 7 regex'. As stated, sed uses basic regex, i.e. +() have no special meaning (when sed sees them, use 'set -x' to find out what sed actually gets). If you want to have them special meaning (grouping for () and "once or more often"), then you need to escape them _for sed_ (see man 7 regex). Mind you: that "escaping for sed" is completely seperated from "escaping in the shell". E.g.: sed s/\\\(.\\\)/X\\\1/g == sed "s/\(.\)/X\1/g" ### remember what you need to escape from ### the shell inside the "" though! == sed 's/\(.\)/X\1/g' != sed 's/(.)/X\1/g' => ERROR: "invalid reference \1 on `s' command's RHS" (there is no "grouping" on the LHS). With '\+' it's analoguous (and \+ is not portable, IIRC, but available in GNU sed for at least 10 years, I think). Again: 'man 7 regex' should clear up most of your misunderstandings. But feel free to ask for further clarifications / explanations (esp. where shell quoting/escaping is involved, that can get quite confusing ;) Ah, while trying to understand 'man 7 regex' _DO_ 'set -x', to see what sed (or grep for that matter) actually get passed from the shell. If you don't, you might get confused by "what's escaped from the shell and what for sed/grep ... Oh, and BTW: within a .spec file it's another level of "fun" added ;P Extra fun, if you "live-patch" a Makefile from a .spec. That's yet another level[1] :) So, the guideline (to use a patch) is a good thing! HTH, -dnh [1] but quite satisfying, once you "get" to work. BTDT. -- Kid, you've got the attention span of a caffeinated hummingbird. -- "Hammer" to "Kid" in Angels 2200 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org