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 3b5ff13641b13de5a84db3026f82d1490b4941ef

Pause on Win, if executing of shell command failed
This was an old one, not sure why wasn't it done before.
Author: xaizek
Author date (UTC): 2013-05-06 09:59
Committer name: xaizek
Committer date (UTC): 2013-05-06 09:59
Parent(s): c4ef5caaf525903c75601b15b4670c1d625f8e63
Signing key:
Tree: 90d3a0f0bdfe0d7682f7ec8fce083659220c0932
File Lines added Lines deleted
ChangeLog 2 0
TODO 2 0
src/running.c 10 3
src/utils/utils.c 10 3
src/utils/utils.h 6 1
File ChangeLog changed (mode: 100644) (index 2c9822264..556d01b08)
20 20 Pause on Windows on failed execution of a help command. Thanks to Pause on Windows on failed execution of a help command. Thanks to
21 21 filterfalse. filterfalse.
22 22
23 Pause on Windows, when executing of shell command fails.
24
23 25 Fixed generation of vifm-help.txt file on Windows (all occurrences of the Fixed generation of vifm-help.txt file on Windows (all occurrences of the
24 26 "[m" sequence were removed). Thanks to Sebastian Cyprych. "[m" sequence were removed). Thanks to Sebastian Cyprych.
25 27
File TODO changed (mode: 100644) (index 168065d95..ee64350b3)
... ... Code improvements.
154 154 Fix code duplication related to composing of undo messages. Fix code duplication related to composing of undo messages.
155 155 Add a function like add_to_string_array(), but which won't duplicate Add a function like add_to_string_array(), but which won't duplicate
156 156 string. string.
157 On Windows check for cmd shell when it's set instead of checking it every
158 time it is used.
File src/running.c changed (mode: 100644) (index 238c98ecd..a11ee928e)
... ... shellout(const char *command, int pause, int allow_screen)
893 893 * subprocess exited. */ * subprocess exited. */
894 894 result = WEXITSTATUS(ec); result = WEXITSTATUS(ec);
895 895
896 #ifndef _WIN32
897 896 if(result != 0 && pause < 0) if(result != 0 && pause < 0)
898 897 { {
899 898 LOG_ERROR_MSG("Subprocess (%s) exit code: %d (0x%x); status = 0x%x", buf, LOG_ERROR_MSG("Subprocess (%s) exit code: %d (0x%x); status = 0x%x", buf,
900 899 result, result, ec); result, result, ec);
901 my_system(PAUSE_CMD);
902 }
900 #ifdef _WIN32
901 if(stroscmp(cfg.shell, "cmd") == 0)
902 {
903 my_system_no_cls("pause");
904 }
905 else
903 906 #endif #endif
907 {
908 my_system_no_cls(PAUSE_CMD);
909 }
910 }
904 911
905 912 /* force views update */ /* force views update */
906 913 request_view_update(&lwin); request_view_update(&lwin);
File src/utils/utils.c changed (mode: 100644) (index ba9056326..13b4c7b71)
... ... static void unquote(char quoted[]);
71 71 #endif #endif
72 72
73 73 int int
74 my_system(char *command)
74 my_system(char command[])
75 {
76 #ifdef _WIN32
77 system("cls");
78 #endif
79 return my_system_no_cls(command);
80 }
81
82 int
83 my_system_no_cls(char command[])
75 84 { {
76 85 #ifndef _WIN32 #ifndef _WIN32
77 86 typedef void (*sig_handler)(int); typedef void (*sig_handler)(int);
 
... ... my_system(char *command)
140 149 #else #else
141 150 char buf[strlen(cfg.shell) + 5 + strlen(command)*4 + 1 + 1]; char buf[strlen(cfg.shell) + 5 + strlen(command)*4 + 1 + 1];
142 151
143 system("cls");
144
145 152 if(stroscmp(cfg.shell, "cmd") == 0) if(stroscmp(cfg.shell, "cmd") == 0)
146 153 { {
147 154 snprintf(buf, sizeof(buf), "%s /C \"%s\"", cfg.shell, command); snprintf(buf, sizeof(buf), "%s /C \"%s\"", cfg.shell, command);
File src/utils/utils.h changed (mode: 100644) (index 2fd1bdf00..b14da0148)
... ... const char * get_regexp_error(int err, regex_t *re);
56 56
57 57 /* Program running. */ /* Program running. */
58 58
59 int my_system(char *command);
59 /* Executes an external command. Clears the screen up on Windows before running
60 * the command. Returns error code, which is zero on success. */
61 int my_system(char command[]);
62 /* Executes an external command without clearing up the screen. Returns error
63 * code, which is zero on success. */
64 int my_system_no_cls(char command[]);
60 65 void _gnuc_noreturn run_from_fork(int pipe[2], int err, char *cmd); void _gnuc_noreturn run_from_fork(int pipe[2], int err, char *cmd);
61 66
62 67 /* Other functions. */ /* Other functions. */
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