Take into account the fact that "[" may be called with a path,

for example "/bin/[".

Reported by:	Vlad Skvortsov <vss@ulstu.ru>
Reported by:	Peter Jeremy <peter.jeremy@alcatel.com.au>
Message-Id:	99Dec27.111307est.40321@border.alcanet.com.au
This commit is contained in:
Sheldon Hearn 1999-12-28 09:34:57 +00:00
parent 920eb79f55
commit 9abf30435b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=55179

View File

@ -163,8 +163,13 @@ main(argc, argv)
char **argv;
{
int res;
char *p;
if (strcmp(argv[0], "[") == 0) {
if ((p = rindex(argv[0], '/')) == NULL)
p = argv[0];
else
p++;
if (strcmp(p, "[") == 0) {
if (strcmp(argv[--argc], "]"))
errx(2, "missing ]");
argv[argc] = NULL;