aboutsummaryrefslogtreecommitdiffstats
path: root/src/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-12-01 07:19:56 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-12-01 07:19:56 +0530
commitef361294db837fdda3460312647f3f9baa99fa76 (patch)
tree86a332acb5af8b602a4d29121d592a24629559ea /src/nnn.c
parent419f365e88acd44987d56d57b57d3d1c6663a908 (diff)
downloadnnn-ef361294db837fdda3460312647f3f9baa99fa76.tar.gz
Get pager with arg
Diffstat (limited to 'src/nnn.c')
-rw-r--r--src/nnn.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 7b41be6..147a354 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -292,6 +292,7 @@ static uint idle;
static uint idletimeout, copybufpos, copybuflen;
static char *copier;
static char *editor, *editor_arg;
+static char *pager, *pager_arg;
static blkcnt_t ent_blocks;
static blkcnt_t dir_blocks;
static ulong num_files;
@@ -863,8 +864,11 @@ static char *xgetenv(const char *name, char *fallback)
return value && value[0] ? value : fallback;
}
-/* Parse a string to return program and argument */
-static int getprogarg(char *prog, char **arg)
+/*
+ * Parse a string to get program and argument
+ * NOTE: original string may be modified
+ */
+static void getprogarg(char *prog, char **arg)
{
char *argptr;
@@ -878,13 +882,13 @@ static int getprogarg(char *prog, char **arg)
/* Make sure there are no more args */
while (*argptr) {
- if (*argptr == ' ')
- return -1;
+ if (*argptr == ' ') {
+ fprintf(stderr, "Too many %s args\n", prog);
+ exit(1);
+ }
++argptr;
}
}
-
- return 0;
}
/* Check if a dir exists, IS a dir and is readable */
@@ -3597,11 +3601,13 @@ int main(int argc, char *argv[])
if (getuid() == 0 || getenv("NNN_SHOW_HIDDEN"))
cfg.showhidden = 1;
+ /* Get VISUAL/EDITOR */
editor = xgetenv("VISUAL", xgetenv("EDITOR", "vi"));
- if (getprogarg(editor, &editor_arg) < 0) {
- fprintf(stderr, "Too many editor args\n");
- exit(1);
- }
+ getprogarg(editor, &editor_arg);
+
+ /* Get PAGER */
+ pager = xgetenv("PAGER", "less");
+ getprogarg(pager, &pager_arg);
/* Edit text in EDITOR, if opted */
if (getenv("NNN_USE_EDITOR"))