Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site hcrvx1.UUCP
Path: utzoo!hcrvax!hcrvx1!hugh
From: hugh@hcrvx1.UUCP (Hugh Redelmeier)
Newsgroups: net.bugs.usg
Subject: basename(1) surprise
Message-ID: <1217@hcrvx1.UUCP>
Date: Wed, 14-Aug-85 18:11:47 EDT
Article-I.D.: hcrvx1.1217
Posted: Wed Aug 14 18:11:47 1985
Date-Received: Thu, 15-Aug-85 07:50:51 EDT
Organization: Human Computing Resources, Toronto
Lines: 19

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