From 8fb3aecde5b250f6c9b6dfd0d7eb43e4d5e2aabd Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sun, 16 Jul 2023 00:28:58 +0100 Subject: [PATCH] Finalise pull from ikasty to show relative filenames in --watchfd --- doc/NEWS.md | 1 + src/pv/state.c | 9 ++++++--- src/pv/watchpid.c | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/NEWS.md b/doc/NEWS.md index 0c27379..65f8803 100644 --- a/doc/NEWS.md +++ b/doc/NEWS.md @@ -1,4 +1,5 @@ UNRELEASED + * The "`--watchfd`" option will now show relative filenames, if they are under the current directory (patch supplied by [ikasty](https://github.com/ikasty)) * support for Red Hat Enterprise Linux and its derivatives has been dropped; removed the RPM spec file, and will no longer build binaries * docs: moved all open issues into GitHub and updated the TODO list * docs: renamed README to README.md and altered it to Markdown format diff --git a/src/pv/state.c b/src/pv/state.c index 7be9dd1..12236a7 100644 --- a/src/pv/state.c +++ b/src/pv/state.c @@ -37,13 +37,16 @@ pvstate_t pv_state_alloc(const char *program_name) #endif /* HAVE_SPLICE */ state->display_visible = false; - //get cwd from system and set to state + /* + * Get the current working directory, if possible, as a base for + * showing relative filenames with --watchfd. + */ if (NULL == getcwd(state->cwd, sizeof(state->cwd))) { - // ignore error, using full path + /* failed - will always show full path */ state->cwd[0] = '\0'; } if ('\0' == state->cwd[1]) { - // ignore when current working directory is root directory + /* CWD is root directory - always show full path */ state->cwd[0] = '\0'; } diff --git a/src/pv/watchpid.c b/src/pv/watchpid.c index abd04dd..9dda7cd 100644 --- a/src/pv/watchpid.c +++ b/src/pv/watchpid.c @@ -363,6 +363,9 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine, /* * Set the display name for the given watched file descriptor, truncating at * the relevant places according to the current screen width. + * + * If the file descriptor is pointing to a file under the current working + * directory, show its relative path, not the full path. */ void pv_watchpid_setname(pvstate_t state, pvwatchfd_t info) {