Implement FreeBSD's -n option to supress comments in the output. Index: mtree.8 =================================================================== --- mtree.8 (revision 240747) +++ mtree.8 (revision 240748) @@ -202,6 +202,13 @@ See .Xr init 8 for information on security levels. +.It Fl n +Do not emit pathname comments when creating a specification. +Normally +a comment is emitted before each directory and before the close of that +directory when using the +.Fl c +option. .It Fl N Ar dbdir Use the user database text file .Pa master.passwd Index: create.c =================================================================== --- create.c (revision 240747) +++ create.c (revision 240748) @@ -112,9 +112,11 @@ ""; } - printf( - "#\t user: %s\n#\tmachine: %s\n#\t tree: %s\n#\t date: %s", - user, host, fullpath, ctime(&clocktime)); + if (!nflag) + printf( + "#\t user: %s\n#\tmachine: %s\n#\t tree: %s\n" + "#\t date: %s", + user, host, fullpath, ctime(&clocktime)); if ((t = fts_open(argv, ftsoptions, dcmp)) == NULL) mtree_err("fts_open: %s", strerror(errno)); @@ -125,12 +127,13 @@ } switch(p->fts_info) { case FTS_D: - printf("\n# %s\n", p->fts_path); + if (!nflag) + printf("\n# %s\n", p->fts_path); statd(t, p, &uid, &gid, &mode, &flags); statf(p); break; case FTS_DP: - if (p->fts_level > 0) + if (!nflag && p->fts_level > 0) printf("# %s\n..\n\n", p->fts_path); break; case FTS_DNR: Index: extern.h =================================================================== --- extern.h (revision 240747) +++ extern.h (revision 240748) @@ -69,7 +69,8 @@ const char *rlink(const char *); int verify(void); -extern int dflag, eflag, iflag, lflag, mflag, rflag, sflag, tflag, uflag; +extern int dflag, eflag, iflag, lflag, mflag, + nflag, rflag, sflag, tflag, uflag; extern int mtree_Mflag, mtree_Sflag, mtree_Wflag; extern size_t mtree_lineno; extern u_int32_t crc_total; Index: mtree.c =================================================================== --- mtree.c (revision 240747) +++ mtree.c (revision 240748) @@ -60,7 +60,7 @@ int ftsoptions = FTS_PHYSICAL; int cflag, Cflag, dflag, Dflag, eflag, iflag, lflag, mflag, - rflag, sflag, tflag, uflag, Uflag; + nflag, rflag, sflag, tflag, uflag, Uflag; char fullpath[MAXPATHLEN]; __dead2 static void usage(void); @@ -77,7 +77,7 @@ init_excludes(); while ((ch = getopt(argc, argv, - "cCdDeE:f:I:ik:K:lLmMN:p:PrR:s:StuUWxX:")) + "cCdDeE:f:I:ik:K:lLmMnN:p:PrR:s:StuUWxX:")) != -1) { switch((char)ch) { case 'c': @@ -132,6 +132,9 @@ case 'M': mtree_Mflag = 1; break; + case 'n': + nflag = 1; + break; case 'N': if (! setup_getid(optarg)) mtree_err( @@ -225,7 +228,7 @@ { fprintf(stderr, - "usage: %s [-CcDdeLlMPrSUuWx] [-i|-m] [-E tags] [-f spec]\n" + "usage: %s [-CcDdeLlMnPrSUuWx] [-i|-m] [-E tags] [-f spec]\n" "\t\t[-I tags] [-K keywords] [-k keywords] [-N dbdir] [-p path]\n" "\t\t[-R keywords] [-s seed] [-X exclude-file]\n", getprogname());