Author: Stan Eisenstat
Subject: CORRECTION regarding wildcards
Date: Monday, 14 Sep 2020, 17:32:39
In answering several posts in involving wildcards, I assumed that bash behavsd the same as tcsh, the shell that I use interactively (vs. in scripts). Thus I claimed various things that are not correct. This post tries to correct these misstatements. I apologize if my previous responses misled you. ===== When bash cannot expand a wildcard into a list of one or `fre files, it passes it to the program. Thus you can give an unescaped wildcard argument with no /'s to fiend as long as no file in the current working directory that matches it. ===== > Subject: Re: [Cs323] Bump: wildcard char in filenames > > Is fiend supposed to be able to deal with wildcard ('*') characters in > filenames? The solution script works with some cases, such as ./fiend * or > ./fiend ../*/*/*.c, but raises a stat error if there are no files that > follow filename regex. If we are supposed to deal with wildcards, is there > a convenient way of processing them, especially if the filename uses many > of them such as ./fiend ../*/src/*log/*.c? As stated in in Hwk1/f20h1.c1; fiend may ignore wildcard characters that appear in filenames. However, you should be aware that bash may expand wildcards on the command line before passing the arguments to fiend. Thus for % ./fiend * bash expands * to a list of all files in the current working directory and passes all of their names to fiend. And for % ./fiend . -name X* if there is a file in the current working directory whose name begins with X, it replaces X* by a list of all such files. If there are no such files, then the command is equivalent to % ./fiend . -name 'X*' which should result in an error message since there is no file named X*. ===== > Subject: Re: [Cs323] Wildcard Follow Up > > Message Posted By: Unknown > > when I do: > > % ./fiend . -name X*, I get no output > > When I do > > % /c/cs323/Hwk1/fiend * -name X*, I also get no output. > > For both, I have no file beginning with X*. As per your last response on > wildcards, is this expected? You stated that both should print out an error. Since there is no local file beginning with X, the command % ./fiend . -name X* is equivalent to % ./fiend . -name 'X*' and there will not be any output unless there is a file lower in the hierarchy whose name that begins with X. Similarly, the command % /c/cs323/Hwk1/fiend * -name X* is equivalent to % /c/cs323/Hwk1/fiend * -name 'X*' where the first * is replaced by a list of files in the current working directory, and the output will be the same as above. ===== > Subject: Re: [Cs323] (Student) Re: Wildcard Follow Up > > Message Posted By: Unknown > > I did some testing, and it looks like if there are no matches for a > wildcard string, C does not modify the wildcard string. So in ./fiend > -name X*, the argument to -name is literally X*, and since there are no > files called X*, there's no output. Yes, if by "C" you meant "bash". --Stan-PREV INDEX NEXT