diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-05-05 14:15:22 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-05-05 14:15:22 +0000 |
| commit | 724d0a049f46f68f24d3eca6c7975d12d37d6062 (patch) | |
| tree | f42bd0eb5974639396e5bfb87702f8453c4c2911 | |
| parent | d26ae76e4c4e09a9e58454743ac995ccbccfd1c2 (diff) | |
| download | execline-724d0a049f46f68f24d3eca6c7975d12d37d6062.tar.gz | |
Change redirfd -v to redirfd -f, for less cognitive load
No matter how much I tried to use -v, it kept coming out as -f.
So, work with the brain, not against it.
| -rw-r--r-- | doc/redirfd.html | 6 | ||||
| -rw-r--r-- | src/execline/redirfd.c | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/doc/redirfd.html b/doc/redirfd.html index 295b603..b64743b 100644 --- a/doc/redirfd.html +++ b/doc/redirfd.html @@ -28,7 +28,7 @@ executes a program. <pre> redirfd [ -r | -w | -u | -a | -x ] [ -n ] [ -b ] <em>fd</em> <em>file</em> <em>prog...</em><br> - redirfd [ -r | -w | -u | -a | -x ] [ -n ] [ -b ] [ -v ] [ -e | -E ] <em>var</em> <em>file</em> <em>prog...</em><br> + redirfd [ -r | -w | -u | -a | -x ] [ -n ] [ -b ] [ -f ] [ -e | -E ] <em>var</em> <em>file</em> <em>prog...</em><br> </pre> <p> @@ -60,10 +60,10 @@ the -n and -b options may be added in any case. <li> <tt>-b</tt> : change mode of <em>file</em> after opening it: to non-blocking mode if the <tt>-n</tt> option was not given, to blocking mode if it was. </li> - <li> <tt>-v</tt> : interpret the first argument as an environment variable, + <li> <tt>-f</tt> : interpret the first argument as an environment variable, and stores the new file descriptor into that variable before execing. </li> <li> <tt>-e</tt> : no autoimport. This is the default. </li> - <li> <tt>-E</tt> : autoimport. This is only useful with the <tt>-v</tt> option. + <li> <tt>-E</tt> : autoimport. This is only useful with the <tt>-f</tt> option. Instead of executing <em>prog...</em>, execute <tt>importas -uSi <em>var</em> <em>prog...</em></tt>. This substitutes <em>var</em> into the command line instead of putting it into diff --git a/src/execline/redirfd.c b/src/execline/redirfd.c index e7f491b..c3562f9 100644 --- a/src/execline/redirfd.c +++ b/src/execline/redirfd.c @@ -10,7 +10,7 @@ #include <execline/execline.h> -#define USAGE "redirfd -[ r | w | u | a | x ] [ -N | -n ] [ -b ] [ -v ] [ -E | -e ] fd file prog..." +#define USAGE "redirfd -[ r | w | u | a | x ] [ -N | -n ] [ -b ] [ -f ] [ -E | -e ] fd|var file prog..." #define dieusage() strerr_dieusage(100, USAGE) enum golb_e @@ -23,7 +23,7 @@ enum golb_e GOLB_EXCL = 0x0020, GOLB_NONBLOCK = 0x0040, GOLB_CHANGEMODE = 0x0100, - GOLB_VAR = 0x0200, + GOLB_OPEN = 0x0200, GOLB_AUTOIMPORT = 0x0400, } ; @@ -39,7 +39,7 @@ int main (int argc, char const *const *argv) { .so = 'N', .lo = "block", .clear = GOLB_NONBLOCK, .set = 0 }, { .so = 'n', .lo = "nonblock", .clear = 0, .set = GOLB_NONBLOCK }, { .so = 'b', .lo = "switch-block", .clear = 0, .set = GOLB_CHANGEMODE }, - { .so = 'v', .lo = "variable", .clear = 0, .set = GOLB_VAR }, + { .so = 'f', .lo = "open", .clear = 0, .set = GOLB_OPEN }, { .so = 'e', .lo = "no-autoimport", .clear = GOLB_AUTOIMPORT, .set = 0 }, { .so = 'E', .lo = "autoimport", .clear = 0, .set = GOLB_AUTOIMPORT }, { .so = 0, .lo = "no-read", .clear = GOLB_READ, .set = 0 }, @@ -66,7 +66,7 @@ int main (int argc, char const *const *argv) argc -= golc ; argv += golc ; if (argc < 3) dieusage() ; if (!(wgolb & (GOLB_READ | GOLB_WRITE))) dieusage() ; - if (!(wgolb & GOLB_VAR)) + if (!(wgolb & GOLB_OPEN)) if (!uint0_scan(argv[0], &fdto)) dieusage() ; flags = @@ -90,7 +90,7 @@ int main (int argc, char const *const *argv) if (wgolb & GOLB_CHANGEMODE) if ((wgolb & GOLB_NONBLOCK ? ndelay_off(fd) : ndelay_on(fd)) == -1) strerr_diefu1sys(111, "change blocking mode") ; - if (wgolb & GOLB_VAR) + if (wgolb & GOLB_OPEN) { char fmt[UINT_FMT] ; fmt[uint_fmt(fmt, fd)] = 0 ; |
