public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Converting shell globs to regular expressions
@ 2023-04-13 16:27 Dr Rainer Woitok
  2023-04-13 23:19 ` David M. Fellows
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dr Rainer Woitok @ 2023-04-13 16:27 UTC (permalink / raw
  To: Gentoo-User

Greetings,

does anybody know about some command to convert shell globs  (shell pat-
terns) into regular expressions?   Back in the old Unix days there was a
"glob" command, but "e-files" only turns up a GNU library.

I am aware  of Python's  "fnmatch.translate()" function,  but this -- of
course -- returns a  Python style  regular expression  which I can't use
together with  "grep" or "gawk".   So using this function  would require
moving and converting the "grep" and "gawk" specific code  from my Shell
script into a separate Python script.   This would be doable,  if neces-
sary, but I would prefer staying with just my Shell script.

Any pointers heartily welcome :-)

Sincerely,
  Rainer


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-user] Converting shell globs to regular expressions
  2023-04-13 16:27 [gentoo-user] Converting shell globs to regular expressions Dr Rainer Woitok
@ 2023-04-13 23:19 ` David M. Fellows
  2023-04-13 23:41 ` Michael Orlitzky
  2023-04-15 14:18 ` [gentoo-user] " Nuno Silva
  2 siblings, 0 replies; 4+ messages in thread
From: David M. Fellows @ 2023-04-13 23:19 UTC (permalink / raw
  To: gentoo-user, Dr Rainer Woitok

>Greetings,
>
>does anybody know about some command to convert shell globs  (shell pat-
>terns) into regular expressions?   Back in the old Unix days there was a
>"glob" command, but "e-files" only turns up a GNU library.

Would one of the functions in
  dev-perl/Text-Glob
do what you need?

DaveF

>
>I am aware  of Python's  "fnmatch.translate()" function,  but this -- of
>course -- returns a  Python style  regular expression  which I can't use
>together with  "grep" or "gawk".   So using this function  would require
>moving and converting the "grep" and "gawk" specific code  from my Shell
>script into a separate Python script.   This would be doable,  if neces-
>sary, but I would prefer staying with just my Shell script.
>
>Any pointers heartily welcome :-)
>
>Sincerely,
>  Rainer
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-user] Converting shell globs to regular expressions
  2023-04-13 16:27 [gentoo-user] Converting shell globs to regular expressions Dr Rainer Woitok
  2023-04-13 23:19 ` David M. Fellows
@ 2023-04-13 23:41 ` Michael Orlitzky
  2023-04-15 14:18 ` [gentoo-user] " Nuno Silva
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Orlitzky @ 2023-04-13 23:41 UTC (permalink / raw
  To: gentoo-user

On Thu, 2023-04-13 at 18:27 +0200, Dr Rainer Woitok wrote:
> Greetings,
> 
> does anybody know about some command to convert shell globs  (shell pat-
> terns) into regular expressions?
> 

What exactly are you trying to do? This sounds like an XY problem
(https://xyproblem.info/).



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [gentoo-user] Re: Converting shell globs to regular expressions
  2023-04-13 16:27 [gentoo-user] Converting shell globs to regular expressions Dr Rainer Woitok
  2023-04-13 23:19 ` David M. Fellows
  2023-04-13 23:41 ` Michael Orlitzky
@ 2023-04-15 14:18 ` Nuno Silva
  2 siblings, 0 replies; 4+ messages in thread
From: Nuno Silva @ 2023-04-15 14:18 UTC (permalink / raw
  To: gentoo-user

On 2023-04-13, Dr Rainer Woitok wrote:

> Greetings,
>
> does anybody know about some command to convert shell globs  (shell pat-
> terns) into regular expressions?   Back in the old Unix days there was a
> "glob" command, but "e-files" only turns up a GNU library.
>
> I am aware  of Python's  "fnmatch.translate()" function,  but this -- of
> course -- returns a  Python style  regular expression  which I can't use
> together with  "grep" or "gawk".   So using this function  would require
> moving and converting the "grep" and "gawk" specific code  from my Shell
> script into a separate Python script.   This would be doable,  if neces-
> sary, but I would prefer staying with just my Shell script.
>
> Any pointers heartily welcome :-)

What did the "glob" utility you remember do? Sources at TUHS have a
"glob" utility, but it seems to execute a given command after expanding
the glob, instead of outputting a translation (which I think is what
you're describing?).

Do you remember which system did you see this on? Perhaps this could be
a question for alt.folklore.computers or a comp.unix.* group on USENET
too!

The "glob" utility at TUHS:
https://minnie.tuhs.org/cgi-bin/utree.pl?file=V5/usr/source/s1/glob.c

and the source for its online manual page from V6:
https://www.tuhs.org/cgi-bin/utree.pl?file=V6%2Fusr%2Fman%2Fman8%2Fglob.8

-- 
Nuno Silva



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-15 14:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-13 16:27 [gentoo-user] Converting shell globs to regular expressions Dr Rainer Woitok
2023-04-13 23:19 ` David M. Fellows
2023-04-13 23:41 ` Michael Orlitzky
2023-04-15 14:18 ` [gentoo-user] " Nuno Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox