]> Sergey Matveev's repositories - nnn.git/commitdiff
Default to CWD for atool
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 19 Jun 2021 08:19:48 +0000 (13:49 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 19 Jun 2021 09:01:04 +0000 (14:31 +0530)
src/nnn.c

index 06eef652b47450a82e8e37a41dab726e82be1390..d5c14df97dc20985f529b6f232e522fa8cdbf9b0 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -4282,11 +4282,12 @@ next:
 static bool handle_archive(char *fpath /* in-out param */, char op)
 {
        char arg[] = "-tvf"; /* options for tar/bsdtar to list files */
-       char *util, *outdir;
+       char *util, *outdir = NULL;
        bool x_to = FALSE;
+       bool is_atool = getutil(utils[UTIL_ATOOL]);
 
        if (op == 'x') {
-               outdir = xreadline(xbasename(fpath), messages[MSG_NEW_PATH]);
+               outdir = xreadline(is_atool ? "." : xbasename(fpath), messages[MSG_NEW_PATH]);
                if (!outdir || !*outdir) { /* Cancelled */
                        printwait(messages[MSG_CANCEL], NULL);
                        return FALSE;
@@ -4303,7 +4304,7 @@ static bool handle_archive(char *fpath /* in-out param */, char op)
                }
        }
 
-       if (getutil(utils[UTIL_ATOOL])) {
+       if (is_atool) {
                util = utils[UTIL_ATOOL];
                arg[1] = op;
                arg[2] = '\0';
@@ -4332,8 +4333,8 @@ static bool handle_archive(char *fpath /* in-out param */, char op)
                        return FALSE;
                }
                xstrsncpy(fpath, outdir, PATH_MAX);
-               free(outdir);
-       }
+       } else if (op == 'x')
+               fpath[0] = '\0';
 
        return TRUE;
 }
@@ -6540,7 +6541,10 @@ nochange:
                                }
 
                                if (r == 'x' || r == 'm') {
-                                       set_smart_ctx('+', newpath, &path, &lastname, &lastdir);
+                                       if (newpath[0])
+                                               set_smart_ctx('+', newpath, &path, &lastname, &lastdir);
+                                       else
+                                               copycurname();
                                        clearfilter();
                                        goto begin;
                                }