hugh@hcrvx1.UUCP (Hugh Redelmeier) (08/15/85)
Under System V the "suffix" operand of basename is a regular expression (under V7 and 4.2BSD it is a literal string). Unfortunately, this is *not* mentioned in the manual. The most common use of basename is to strip suffixes beginning with dot; if the programmer fails to quote the dot twice (once for the shell, and once for basename's pattern matcher) it will match any character. Thus basename cccc .c yields cc There is a slight hint in the manual in that the sample use of basename has the required quoting (and thus should not work!). Since System V's basename is implemented as a shell script, I guess dollar signs in suffix must be quoted three times. On the other hand, you can read the code even if you do not have a source license. Hugh Redelmeier (416) 922-1937 {utzoo, ihnp4, decvax}!hcr!hugh
jsp@icdoc.UUCP (Jan-Simon Pendry) (08/22/85)
In article <1217@hcrvx1.UUCP> hugh@hcrvx1.UUCP (Hugh Redelmeier) writes: >Under System V the "suffix" operand of basename is a regular expression > ... if the programmer fails to >quote the dot twice (once for the shell, and once for basename's >pattern matcher) it will match any character. Thus > basename cccc .c >yields > cc Not on my System V machines! The example above prints "cccc". Of course - it could be the particular implementation but I see no need for a manufacturer to alter a shell script. [The software is based on SysVr2 for Vax.] -- Jan-Simon Pendry icdoc!jsp
gwyn@brl-tgr.ARPA (08/28/85)
> In article <1217@hcrvx1.UUCP> hugh@hcrvx1.UUCP (Hugh Redelmeier) writes: > >Under System V the "suffix" operand of basename is a regular expression > > ... if the programmer fails to > >quote the dot twice (once for the shell, and once for basename's > >pattern matcher) it will match any character. Thus > > basename cccc .c > >yields > > cc > > Not on my System V machines! The example above prints "cccc". > Of course - it could be the particular implementation but I see no > need for a manufacturer to alter a shell script. [The software > is based on SysVr2 for Vax.] Funny; "basename" version 1.4 (SVR2 VAX) has the problem Hugh reported.