[Info-vax] Unix and DCL shells

mjos_examine m6502x64 at gmail.com
Fri Jan 12 15:22:41 EST 2024


On 2024-01-12 8:21 a.m., Simon Clubley wrote:
> On 2024-01-11, Lawrence D'Oliveiro <ldo at nz.invalid> wrote:
>> On Thu, 11 Jan 2024 13:52:52 -0000 (UTC), Simon Clubley wrote:
>>
>>> Fine. Then add the globbing pattern capabilities to the current VMS
>>> wildcard lookup APIs without changing anything else. That gives you the
>>> same ability to use more powerful pattern matching expressions on VMS
>>> without having to change anything else in your code.
>>
>> I?m not really sure that?s worthwhile. One could argue that the existing
>> VMS wildcard patterns are already equivalent in power (or a bit beyond, in
>> the case of ?...?), based on the corresponding constructs in the filename
>> specs.
>>
> 
> The main thing missing on VMS is that you can't use a grouping
> operator such as [a-d] to restrict the files selected or to select
> everyting not in the grouping operator. There's nothing similar
> to the {} expansion operator either.
> 
> I use that kind of selection criteria all the time on Linux.
> 
> Simon.
> 

$ dir *.txt

Directory DKA100:[test]

atest.txt;1         btest.txt;1         ctest.txt;1         dtest.txt;1
etest.txt;1         ftest.txt;1         gtest.txt;1

Total of 7 files.

$
$
$ type testglob.c
/* -------- start of testglob.c --------- */
/* experimenting with RTL glob on OpenVMS */

#include <stdio.h>
#include <glob.h>
/*
  * From:
  * 
https://docs.vmssoftware.com/vsi-c-run-time-library-reference-manual-for-openvms-systems/
  * The glob function defaults to OpenVMS mode unless one of the
  * following conditions is met (in which case glob uses UNIX mode):
  *  - The DECC$GLOB_UNIX_STYLE is enabled.
  *  - The DECC$FILENAME_UNIX_ONLY feature logical is enabled.
  *  - The glob function checks the specified pattern for pathname
  *    indications, such as directory delimiters, and determines it to
  *    be a UNIX style pathname.
  */

int main(int argc, char *argv[])
{
     const char *mypattern = "[a-c]*";
     glob_t myglob;
     int result;
     size_t count;

     printf("pattern is:%s\n", mypattern);
     result = glob(mypattern, 0, NULL, &myglob);
     if (result == 0) {
         for (count = 0; count < myglob.gl_pathc; ++count) {
             if (myglob.gl_pathv) {
                 printf("%s\n", myglob.gl_pathv[count]);
             }
         }
         globfree(&myglob);
     } else {
         printf("glob() failed (%s).\n",
                  (result == GLOB_ABORTED) ? "GLOB_ABORTED"
                : (result == GLOB_NOMATCH) ? "GLOB_NOMATCH"
                : (result == GLOB_NOSPACE) ? "GLOB_NOSPACE"
                : "unknown error");
     }
}
/* -------- end of testglob.c --------- */
$ cc testglob.c
$ link testglob
$ run testglob
pattern is:[a-c]*
glob() failed (GLOB_NOMATCH).
$
$ DEFINE DECC$GLOB_UNIX_STYLE ENABLE
$
$ run testglob
pattern is:[a-c]*
atest.txt
btest.txt
ctest.txt
$ DEAS DECC$GLOB_UNIX_STYLE
$




More information about the Info-vax mailing list