basename(1) surprise
Hugh Redelmeier
hugh at hcrvx1.UUCP
Thu Aug 15 08:11:47 AEST 1985
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
More information about the Net.bugs.usg
mailing list