Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/stat Honor the -t option to set the time format when...
details: https://anonhg.NetBSD.org/src/rev/30979acbb19f
branches: trunk
changeset: 783062:30979acbb19f
user: erh <erh%NetBSD.org@localhost>
date: Sun Dec 02 21:13:07 2012 +0000
description:
Honor the -t option to set the time format when running stat -s.
Document the format used by -s on the man page.
diffstat:
usr.bin/stat/stat.1 | 13 ++++++++++++-
usr.bin/stat/stat.c | 10 ++++++----
2 files changed, 18 insertions(+), 5 deletions(-)
diffs (72 lines):
diff -r d5b8edd8800a -r 30979acbb19f usr.bin/stat/stat.1
--- a/usr.bin/stat/stat.1 Sun Dec 02 20:27:10 2012 +0000
+++ b/usr.bin/stat/stat.1 Sun Dec 02 21:13:07 2012 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: stat.1,v 1.34 2011/09/22 20:23:55 apb Exp $
+.\" $NetBSD: stat.1,v 1.35 2012/12/02 21:13:07 erh Exp $
.\"
.\" Copyright (c) 2002-2011 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -168,6 +168,17 @@
When run as
.Nm readlink ,
suppress error messages.
+This is equivalent to specifying
+.Bd -literal
+FMT="st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l st_uid=%u st_gid=%g"
+FMT="$FMT st_rdev=%r st_size=%z st_atime=%Sa st_mtime=%Sm st_ctime=%Sc"
+FMT="$FMT st_birthtime=%SB st_blksize=%k st_blocks=%b st_flags=%f"
+stat -t %s -f "$FMT" .
+.Ed
+Note that if you use a timeformat that contains embedded whitespace or shell
+meta-characters you will need to include appropriate quoting so the
+.Fl s
+output remains valid.
.It Fl t Ar timefmt
Display timestamps using the specified format.
This format is
diff -r d5b8edd8800a -r 30979acbb19f usr.bin/stat/stat.c
--- a/usr.bin/stat/stat.c Sun Dec 02 20:27:10 2012 +0000
+++ b/usr.bin/stat/stat.c Sun Dec 02 21:13:07 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: stat.c,v 1.36 2011/09/22 20:23:56 apb Exp $ */
+/* $NetBSD: stat.c,v 1.37 2012/12/02 21:13:07 erh Exp $ */
/*
* Copyright (c) 2002-2011 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: stat.c,v 1.36 2011/09/22 20:23:56 apb Exp $");
+__RCSID("$NetBSD: stat.c,v 1.37 2012/12/02 21:13:07 erh Exp $");
#endif
#if ! HAVE_NBTOOL_CONFIG_H
@@ -76,7 +76,7 @@
#if HAVE_STRUCT_STAT_ST_BIRTHTIME
#define DEF_B "\"%SB\" "
#define RAW_B "%B "
-#define SHELL_B "st_birthtime=%B "
+#define SHELL_B "st_birthtime=%SB "
#else /* HAVE_STRUCT_STAT_ST_BIRTHTIME */
#define DEF_B
#define RAW_B
@@ -99,7 +99,7 @@
#define SHELL_FORMAT \
"st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l " \
"st_uid=%u st_gid=%g st_rdev=%r st_size=%z " \
- "st_atime=%a st_mtime=%m st_ctime=%c " SHELL_B \
+ "st_atime=%Sa st_mtime=%Sm st_ctime=%Sc " SHELL_B \
"st_blksize=%k st_blocks=%b" SHELL_F
#define LINUX_FORMAT \
" File: \"%N\"%n" \
@@ -299,6 +299,8 @@
break;
case 's':
statfmt = SHELL_FORMAT;
+ if (timefmt == NULL)
+ timefmt = "%s";
break;
case 'x':
statfmt = LINUX_FORMAT;
Home |
Main Index |
Thread Index |
Old Index