to OR the clauses; so here is a test I'm trying on MSYS2, Windows 10: $ uname -s MSYS_NT-10.0-18363 $ git --...|
I'll post this as an answer - after looking into
$ uname -s
MSYS_NT-10.0-18363
$ git --version
git version 2.25.2
$ grep --version | head -1
grep (GNU grep) 3.0
$ git clone https://github.com/xythobuz/avrSerial.git
...
$ cd avrSerial/
$ grep -r 'SERIALDATA\|UART_INTERRUPT_MASK' . --include='*.[ch]'
./serial.c:#define SERIALDATA 0
./serial.c: rxBuffer[uart][rxWrite[uart]] = *serialRegisters[uart][SERIALDATA];
./serial.c: *serialRegisters[uart][SERIALDATA] = sendThisNext[uart];
./serial.c: *serialRegisters[uart][SERIALDATA] = txBuffer[uart][txRead[uart]];
./serial.c: serialRegisters[uart]->CTRLA &= ~(UART_INTERRUPT_MASK << 2); // TXCINTLVL
./serial_device.h:#define UART_INTERRUPT_MASK 0x03
, and brute forcing some switches, found that this works on MSYS2:grep
and also this:
So, use either git grep
or -p
- and do not escape the pipe
$ git grep -p 'SERIALDATA\|UART_INTERRUPT_MASK' -- '*.[ch]'
$
with a backslash
, as one needs to do for usual
$ echo `uname -s` `cat /etc/issue | head -1`
Linux Ubuntu 18.04.4 LTS \n \l
$ git --version
git version 2.17.1
$ grep --version | head -1
grep (GNU grep) 3.1
# same procedure with git clone, cd ... grep -r works the same too; but git grep -p is different:
$ git grep -p 'SERIALDATA\|UART_INTERRUPT_MASK' -- '*.[ch]'
serial.c:#define SERIALDATA 0
serial.c=static void serialReceiveInterrupt(uint8_t uart) {
serial.c: rxBuffer[uart][rxWrite[uart]] = *serialRegisters[uart][SERIALDATA];
serial.c=static void serialTransmitInterrupt(uint8_t uart) {
serial.c: *serialRegisters[uart][SERIALDATA] = sendThisNext[uart];
serial.c: *serialRegisters[uart][SERIALDATA] = txBuffer[uart][txRead[uart]];
serial.c: serialRegisters[uart]->CTRLA &= ~(UART_INTERRUPT_MASK << 2); // TXCINTLVL
serial_device.h=uint8_t const serialBits[UART_COUNT][UART_BITS] = {{
serial_device.h:#define UART_INTERRUPT_MASK 0x03
.
到OR的子句;所以这里是我在MSYS2,Windows 10上尝试的一个测试。git grep
所以,只要 git
在这里很好用,多个子句用管道。
但是,我想知道分句关键字匹配发生在哪些C函数中,所以我尝试用 git grep
随着
...这里就可以了?git help grep
有谁知道为什么在这里会出现不同的行为?
$ git grep -p --extended-regexp 'UART_INTERRUPT_MASK|SERIALDATA' -- '*.[ch]'
serial.c:#define SERIALDATA 0
serial.c=static void serialReceiveInterrupt(uint8_t uart) {
serial.c: rxBuffer[uart][rxWrite[uart]] = *serialRegisters[uart][SERIALDATA];
serial.c=static void serialTransmitInterrupt(uint8_t uart) {
serial.c: *serialRegisters[uart][SERIALDATA] = sendThisNext[uart];
serial.c: *serialRegisters[uart][SERIALDATA] = txBuffer[uart][txRead[uart]];
serial.c: serialRegisters[uart]->CTRLA &= ~(UART_INTERRUPT_MASK << 2); // TXCINTLVL
serial_device.h=uint8_t const serialBits[UART_COUNT][UART_BITS] = {{
serial_device.h:#define UART_INTERRUPT_MASK 0x03
在这些系统上?是否有一个git配置设置,我必须启用,或者是一个回归在
$ git grep -p --perl-regexp 'UART_INTERRUPT_MASK|SERIALDATA' -- '*.[ch]'
serial.c:#define SERIALDATA 0
serial.c=static void serialReceiveInterrupt(uint8_t uart) {
serial.c: rxBuffer[uart][rxWrite[uart]] = *serialRegisters[uart][SERIALDATA];
serial.c=static void serialTransmitInterrupt(uint8_t uart) {
serial.c: *serialRegisters[uart][SERIALDATA] = sendThisNext[uart];
serial.c: *serialRegisters[uart][SERIALDATA] = txBuffer[uart][txRead[uart]];
serial.c: serialRegisters[uart]->CTRLA &= ~(UART_INTERRUPT_MASK << 2); // TXCINTLVL
serial_device.h=uint8_t const serialBits[UART_COUNT][UART_BITS] = {{
serial_device.h:#define UART_INTERRUPT_MASK 0x03
或者MSYS2上有一些shell逃逸的问题?--perl-regexp
或者在一般情况下--我怎样才能得到同样的效果?--extended-regexp
在MSYS2上的响应,就像我在Ubuntu上得到的一样?|
\
grep
我想用grep搜索多个子句--我知道可以用一个管子