summaryrefslogtreecommitdiffstats
path: root/bin/ls/print.c
diff options
context:
space:
mode:
authorgrog <grog@FreeBSD.org>2008-04-04 03:57:46 +0000
committergrog <grog@FreeBSD.org>2008-04-04 03:57:46 +0000
commit8eda00926b2f908b551b3656a532cdbb9d195090 (patch)
tree61e1202cf7aad4a2719fd37121eddd11df8eb842 /bin/ls/print.c
parentd698c6ef567a3b96c01ea7adff77c79aaae7889a (diff)
downloadFreeBSD-src-8eda00926b2f908b551b3656a532cdbb9d195090.zip
FreeBSD-src-8eda00926b2f908b551b3656a532cdbb9d195090.tar.gz
Add -D option to specify exact format of date and time output with ls -l.
Diffstat (limited to 'bin/ls/print.c')
-rw-r--r--bin/ls/print.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/bin/ls/print.c b/bin/ls/print.c
index 6578b93..479b772 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -168,7 +168,7 @@ printlong(const DISPLAY *dp)
prevdev = sp->st_dev;
}
np = p->fts_pointer;
- (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink,
+ (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink,
sp->st_nlink, dp->s_user, np->user, dp->s_group,
np->group);
if (f_flags)
@@ -237,7 +237,7 @@ printstream(const DISPLAY *dp)
if (chcnt)
putchar('\n');
}
-
+
void
printcol(const DISPLAY *dp)
{
@@ -378,17 +378,20 @@ printtime(time_t ftime)
now = time(NULL);
#define SIXMONTHS ((365 / 2) * 86400)
- if (f_sectime)
+ if (f_timeformat) /* user specified format */
+ format = f_timeformat;
+ else if (f_sectime)
/* mmm dd hh:mm:ss yyyy || dd mmm hh:mm:ss yyyy */
- format = d_first ? "%e %b %T %Y " : "%b %e %T %Y ";
+ format = d_first ? "%e %b %T %Y" : "%b %e %T %Y";
else if (ftime + SIXMONTHS > now && ftime < now + SIXMONTHS)
/* mmm dd hh:mm || dd mmm hh:mm */
- format = d_first ? "%e %b %R " : "%b %e %R ";
+ format = d_first ? "%e %b %R" : "%b %e %R";
else
/* mmm dd yyyy || dd mmm yyyy */
- format = d_first ? "%e %b %Y " : "%b %e %Y ";
+ format = d_first ? "%e %b %Y" : "%b %e %Y";
strftime(longstring, sizeof(longstring), format, localtime(&ftime));
fputs(longstring, stdout);
+ fputc(' ', stdout);
}
static int
@@ -625,7 +628,7 @@ aclmode(char *buf, const FTSENT *p, int *haveacls)
snprintf(name, sizeof(name), "%s", p->fts_name);
else
snprintf(name, sizeof(name), "%s/%s",
- p->fts_parent->fts_accpath, p->fts_name);
+ p->fts_parent->fts_accpath, p->fts_name);
/*
* We have no way to tell whether a symbolic link has an ACL since
* pathconf() and acl_get_file() both follow them. They also don't
OpenPOWER on IntegriCloud