xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 29ad6652d3ff22d8b331b54650c1434dae76feff

Don't print newline on cancelling --choose-dir
Thanks to The Cyberduck.

See https://q2a.vifm.info/2195/how-to-make-vifm-choose-a-single-file
Author: xaizek
Author date (UTC): 2025-07-19 13:18
Committer name: xaizek
Committer date (UTC): 2025-07-19 13:18
Parent(s): 7c555035b6f4f7db727e811e79f8fa251ebd8a33
Signing key: 99DC5E4DB05F6BE2
Tree: 775a8c2f3050d464f8bc9cfcec03eda870994c58
File Lines added Lines deleted
ChangeLog 3 0
src/int/vim.c 10 4
tests/misc/integration.c 35 0
File ChangeLog changed (mode: 100644) (index ee0b8646c..3c26734a1)
125 125
126 126 Fixed escaping characters with codes greater than 127 producing garbage. Fixed escaping characters with codes greater than 127 producing garbage.
127 127
128 Fixed printing newline on cancelling choosing a directory via
129 `--choose-dir` option. Thanks to The Cyberduck.
130
128 131 0.14-beta to 0.14 (2025-02-08) 0.14-beta to 0.14 (2025-02-08)
129 132
130 133 Improved documentation on zh/zl menu keys a bit. Improved documentation on zh/zl menu keys a bit.
File src/int/vim.c changed (mode: 100644) (index 1475c6bcb..d24b915c3)
... ... vim_write_dir(const char path[])
345 345
346 346 if(strcmp(dir_out, "-") == 0) if(strcmp(dir_out, "-") == 0)
347 347 { {
348 fputs(path, curr_stats.original_stdout);
349 putc('\n', curr_stats.original_stdout);
348 if(strcmp(path, "") != 0)
349 {
350 fputs(path, curr_stats.original_stdout);
351 putc('\n', curr_stats.original_stdout);
352 }
350 353 return; return;
351 354 } }
352 355
 
... ... vim_write_dir(const char path[])
357 360 return; return;
358 361 } }
359 362
360 fputs(path, fp);
361 putc('\n', fp);
363 if(strcmp(path, "") != 0)
364 {
365 fputs(path, fp);
366 putc('\n', fp);
367 }
362 368 fclose(fp); fclose(fp);
363 369 } }
364 370
File tests/misc/integration.c changed (mode: 100644) (index 5605fadfa..c261e566b)
... ... TEARDOWN()
40 40 /* Because of fmemopen(). */ /* Because of fmemopen(). */
41 41 #if !defined(_WIN32) && !defined(__APPLE__) #if !defined(_WIN32) && !defined(__APPLE__)
42 42
43 TEST(writing_no_dir_choice_on_stdout_omits_newline)
44 {
45 char out_buf[100] = { };
46 char out_spec[] = "-";
47
48 curr_stats.chosen_dir_out = out_spec;
49 curr_stats.original_stdout = fmemopen(out_buf, sizeof(out_buf), "w");
50
51 vim_write_dir("");
52
53 fclose(curr_stats.original_stdout);
54 curr_stats.original_stdout = NULL;
55 curr_stats.chosen_dir_out = NULL;
56
57 assert_string_equal("", out_buf);
58 }
59
43 60 TEST(writing_directory_on_stdout_prints_newline) TEST(writing_directory_on_stdout_prints_newline)
44 61 { {
45 62 char out_buf[100] = { }; char out_buf[100] = { };
 
... ... TEST(writing_directory_on_stdout_prints_newline)
57 74 assert_string_equal("/some/path\n", out_buf); assert_string_equal("/some/path\n", out_buf);
58 75 } }
59 76
77 TEST(writing_no_dir_choice_to_a_file_omits_newline)
78 {
79 char out_buf[100] = { };
80 char out_spec[] = SANDBOX_PATH "/out";
81
82 curr_stats.chosen_dir_out = out_spec;
83 curr_stats.original_stdout = fmemopen(out_buf, sizeof(out_buf), "w");
84
85 vim_write_dir("");
86
87 fclose(curr_stats.original_stdout);
88 curr_stats.original_stdout = NULL;
89 curr_stats.chosen_dir_out = NULL;
90
91 assert_int_equal(0, get_file_size(out_spec));
92 remove_file(out_spec);
93 }
94
60 95 TEST(writing_directory_to_a_file_prints_newline) TEST(writing_directory_to_a_file_prints_newline)
61 96 { {
62 97 char out_buf[100] = { }; char out_buf[100] = { };
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master