From 9926fe30369ff200f331ae076c67c84925eb9856 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Fri, 16 Apr 2021 09:30:31 +0200 Subject: [PATCH] allow glob pattern in var command Conflicts: documentation/RELEASE_NOTES.md --- documentation/RELEASE_NOTES.md | 5 +++++ modules/libcom/src/iocsh/iocsh.cpp | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index cd427fc85..4b3ecc997 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -17,6 +17,11 @@ should also be read to understand what has changed since earlier releases. +### Glob pattern allowed in `var` command + +When used with one argument, the `var` command can be used with a glob pattern +for printing matching variables. + ### Fix for input links marked "special" The calcout record (and a number of synApps record types) marks its input diff --git a/modules/libcom/src/iocsh/iocsh.cpp b/modules/libcom/src/iocsh/iocsh.cpp index 474436c72..753dd2c23 100644 --- a/modules/libcom/src/iocsh/iocsh.cpp +++ b/modules/libcom/src/iocsh/iocsh.cpp @@ -1130,6 +1130,16 @@ static void varCallFunc(const iocshArgBuf *args) for (v = iocshVariableHead ; v != NULL ; v = v->next) varHandler(v->pVarDef, args[1].sval); } + else if(args[1].sval == NULL) { + int found = 0; + for (v = iocshVariableHead ; v != NULL ; v = v->next) + if (epicsStrGlobMatch(v->pVarDef->name, args[0].sval) != 0) { + varHandler(v->pVarDef, NULL); + found = 1; + } + if (!found) + fprintf(epicsGetStderr(), "No var matching %s found.\n", args[0].sval); + } else { v = (iocshVariable *)registryFind(iocshVarID, args[0].sval); if (v == NULL) {