summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2006-04-02 18:51:32 +0000
committerstefanf <stefanf@FreeBSD.org>2006-04-02 18:51:32 +0000
commit8d43248fc1256a9b644eff05327889ec32f7989e (patch)
tree9b6322d6de171bc6da68832378d18a7389d9442e /bin/sh
parent0db401540e16ebc8779d7806d228249018f618ea (diff)
downloadFreeBSD-src-8d43248fc1256a9b644eff05327889ec32f7989e.zip
FreeBSD-src-8d43248fc1256a9b644eff05327889ec32f7989e.tar.gz
Issue an error when . (dot) is invoked without a filename. The synopsis
is just ". file" according to POSIX, however many other shells allow arguments to be passed after the file. For compatibility (we even use that feature in buildworld) additional arguments are not considered to be an error, even though this shell does not do anything with the arguments at all.
Diffstat (limited to 'bin/sh')
-rw-r--r--bin/sh/main.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/bin/sh/main.c b/bin/sh/main.c
index 5ad69f2..a23efd0 100644
--- a/bin/sh/main.c
+++ b/bin/sh/main.c
@@ -316,19 +316,21 @@ int
dotcmd(int argc, char **argv)
{
struct strlist *sp;
+ char *fullname;
+
+ if (argc < 2)
+ error("missing filename");
+
exitstatus = 0;
for (sp = cmdenviron; sp ; sp = sp->next)
setvareq(savestr(sp->text), VSTRFIXED|VTEXTFIXED);
- if (argc >= 2) { /* That's what SVR2 does */
- char *fullname = find_dot_file(argv[1]);
-
- setinputfile(fullname, 1);
- commandname = fullname;
- cmdloop(0);
- popfile();
- }
+ fullname = find_dot_file(argv[1]);
+ setinputfile(fullname, 1);
+ commandname = fullname;
+ cmdloop(0);
+ popfile();
return exitstatus;
}
OpenPOWER on IntegriCloud