I use the linux shell for a weekend job, and I am having trouble implementing wilcard matching as a function in the shell. As we all know, shells are a complete language in themselves, for example. bash, ksh, etc. I do not need to implement functions such as control structures, tasks, etc. But how to implement * ?
A quick analysis gives the following result:
echo *
lists all files in the current directory. Is this the only logical manifestation of the shell? I mean, not considering the language-specific bash functions, is that what the shell does inside? Replace * with all files in the current directory matching the pattern?
I also heard about Perl Compatible Regular Expression, but it seems difficult to use a third-party library.
Any suggestions, links, etc.? I will also try to look at the source code for bash.
source share