summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-07-24 19:30:41 -0400
committerTavian Barnes <tavianator@tavianator.com>2018-07-24 19:34:34 -0400
commitc9280082b774bb8ec8aba7560887d21a661eee0e (patch)
treead2cad2f25f5e0a95f926c64676d718941610cec
parent199063ab53cbae3b3be199ff902f9f2d001d1058 (diff)
downloadbfs-c9280082b774bb8ec8aba7560887d21a661eee0e.tar.xz
printf: Support %B, GNU find's undocumented birth time specifier
-rw-r--r--printf.c11
-rwxr-xr-xtests.sh4
2 files changed, 8 insertions, 7 deletions
diff --git a/printf.c b/printf.c
index 0e9110e..d57c570 100644
--- a/printf.c
+++ b/printf.c
@@ -100,7 +100,7 @@ static const struct timespec *get_time_field(const struct bfs_stat *statbuf, enu
}
}
-/** %c, %c, and %t: ctime() */
+/** %a, %c, %t: ctime() */
static int bfs_printf_ctime(FILE *file, const struct bfs_printf_directive *directive, const struct BFTW *ftwbuf) {
// Not using ctime() itself because GNU find adds nanoseconds
static const char *days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
@@ -129,7 +129,7 @@ static int bfs_printf_ctime(FILE *file, const struct bfs_printf_directive *direc
return fprintf(file, directive->str, buf);
}
-/** %A, %C, %T: strftime() */
+/** %A, %B/%W, %C, %T: strftime() */
static int bfs_printf_strftime(FILE *file, const struct bfs_printf_directive *directive, const struct BFTW *ftwbuf) {
const struct timespec *ts = get_time_field(ftwbuf->statbuf, directive->stat_field);
if (!ts) {
@@ -735,15 +735,16 @@ struct bfs_printf *parse_bfs_printf(const char *format, struct cmdline *cmdline)
case 'A':
directive->stat_field = BFS_STAT_ATIME;
goto directive_strftime;
+ case 'B':
+ case 'W':
+ directive->stat_field = BFS_STAT_BTIME;
+ goto directive_strftime;
case 'C':
directive->stat_field = BFS_STAT_CTIME;
goto directive_strftime;
case 'T':
directive->stat_field = BFS_STAT_MTIME;
goto directive_strftime;
- case 'W':
- directive->stat_field = BFS_STAT_BTIME;
- goto directive_strftime;
directive_strftime:
directive->fn = bfs_printf_strftime;
diff --git a/tests.sh b/tests.sh
index b861760..8532d10 100755
--- a/tests.sh
+++ b/tests.sh
@@ -1418,8 +1418,8 @@ function test_printf_nul() {
}
function test_printf_w() {
- # Birth times may not be supported, so just check that %w/%W can be parsed
- bfs_diff times -false -printf '%w %WY\n'
+ # Birth times may not be supported, so just check that %w/%W/%B can be parsed
+ bfs_diff times -false -printf '%w %WY %BY\n'
}
function test_printf_Y_error() {