summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorRyo Nakamura <upa@haeena.net>2023-03-04 19:01:44 +0900
committerRyo Nakamura <upa@haeena.net>2023-03-04 19:01:44 +0900
commitd766b3a99e1606629c5ce4a817c3fa9fd9b5c15c (patch)
tree8df169c1c8851afc16e3d694a8d5ccef1e7566b5 /src/main.c
parentd5a86292b7d535451ced924124af9cf47be07a3f (diff)
fix dryrun handling on main.c
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 59a736c..8bea783 100644
--- a/src/main.c
+++ b/src/main.c
@@ -44,7 +44,7 @@ void usage(bool print_help) {
"\n"
" -v increment verbose output level\n"
" -q disable output\n"
- " -D dry run\n"
+ " -D dry run. check copy destinations with -vvv\n"
" -r no effect\n"
"\n"
" -l LOGIN_NAME login name\n"
@@ -197,6 +197,7 @@ int main(int argc, char **argv)
int pipe_fd[2];
int ch, n, i, ret;
char *remote;
+ bool dryrun = false;
memset(&s, 0, sizeof(s));
memset(&o, 0, sizeof(o));
@@ -234,7 +235,7 @@ int main(int argc, char **argv)
o.severity = MSCP_SEVERITY_NONE;
break;
case 'D':
- o.dryrun = true;
+ dryrun = true;
break;
case 'r':
/* for compatibility with scp */
@@ -319,13 +320,14 @@ int main(int argc, char **argv)
remote = t[i - 1].remote;
}
- if (pipe(pipe_fd) < 0) {
- fprintf(stderr, "pipe: %s\n", strerrno());
- return -1;
+ if (!dryrun) {
+ if (pipe(pipe_fd) < 0) {
+ fprintf(stderr, "pipe: %s\n", strerrno());
+ return -1;
+ }
+ msg_fd = pipe_fd[0];
+ o.msg_fd = pipe_fd[1];
}
- msg_fd = pipe_fd[0];
- o.msg_fd = pipe_fd[1];
-
if ((m = mscp_init(remote, &o, &s)) == NULL) {
fprintf(stderr, "mscp_init: %s\n", mscp_get_error());
@@ -354,6 +356,11 @@ int main(int argc, char **argv)
return -1;
}
+ if (dryrun) {
+ ret = 0;
+ goto out;
+ }
+
if (pthread_create(&tid_stat, NULL, print_stat_thread, NULL) < 0) {
fprintf(stderr, "pthread_create: %s\n", strerrno());
return -1;
@@ -373,6 +380,7 @@ int main(int argc, char **argv)
pthread_cancel(tid_stat);
pthread_join(tid_stat, NULL);
+out:
mscp_cleanup(m);
mscp_free(m);