3 ms·
this is intentional, since you can store your regular expression in a variable: $ a=BCD; b=.C.; [[ $a =~ $b ]]; echo $?; [[ $a =~ "$b" ]]; echo $? otherwi
by Hello71 8y ago
this is intentional, since you can store your regular expression in a variable:
$ a=BCD; b=.C.; [[ $a =~ $b ]]; echo $?; [[ $a =~ "$b" ]]; echo $?
otherwise, interpolating variables in regular expressions as text would require other syntax (more confusing).
also, "cat -" is redundant, use "cat". this behavior is specified by POSIX.
- floatingatoll 8y agoI use “cat -“ so that my code makes more sense to people. I want STDIN declared somehow, and the dash is effective. Technically I shouldn’t have bothered with the cat at all in an HN code snippet, but it was a courtesy to provide a familiar environment for the block I wanted to convey. It worked so well that you linted it! I really appreciate the thought.