mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Enable extended pattern matching
So that the exclude options can also work as include using special pattern syntax. For example, to only include /dev/ttyUSB* devices simply do: $ tio --exclude-devices=!(/dev/ttyUSB*) --list See the man page of fnmatch() for all available extended pattern options.
This commit is contained in:
parent
d8fb141bc4
commit
8ead9337d1
1 changed files with 2 additions and 1 deletions
|
|
@ -19,6 +19,7 @@
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _GNU_SOURCE // For FNM_EXTMATCH
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
@ -197,7 +198,7 @@ bool match_patterns(const char *string, const char *patterns)
|
||||||
while (pattern != NULL)
|
while (pattern != NULL)
|
||||||
{
|
{
|
||||||
// Check if the string matches the current pattern
|
// Check if the string matches the current pattern
|
||||||
if (fnmatch(pattern, string, 0) == 0)
|
if (fnmatch(pattern, string, FNM_EXTMATCH) == 0)
|
||||||
{
|
{
|
||||||
free(patterns_copy);
|
free(patterns_copy);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue