om

om - the most recently modified file in a directory
git clone git://git.larryhynes.net/om
Log | Files | Refs | README | LICENSE

commit addc3ee160733c9b719c45f2336c69addf1634e3
parent fff614f04d1944253741033658eb13e727bd0542
Author: Larry Hynes <larry@larryhynes.com>
Date:   Thu, 13 Jul 2017 01:21:30 +0100

Don't just check for a single trailing slash

Diffstat:
om.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/om.c b/om.c @@ -20,7 +20,7 @@ char res[NAME_MAX]; int r = 0; /* - * Check for, and remove, a trailing slash on the directory, + * Check for, and remove, trailing slashes on the directory, * unless the directory is '/'. */ char @@ -28,8 +28,10 @@ char { if (strcmp(dir, "/") != 0) { size_t len = strlen(dir); - if (dir[len - 1] == '/') + while (dir[len - 1] == '/') { dir[len - 1] = '\0'; + len = strlen(dir); + } } else { r = 1; }