summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorNed T. Crigler <crigler@users.sourceforge.net>2015-07-18 13:13:09 -0700
committerNed T. Crigler <crigler@users.sourceforge.net>2015-07-18 13:13:09 -0700
commit087e89f7a8fecba3e8d276ab9808f10e6077784b (patch)
tree7c0e6148ec590c989632416031711437b1e626bb /main.c
parentb7d5154c18cb57dd5680114315fbc4175cf1ea26 (diff)
Add dtach -p.
dtach -p copies the contents of standard input to a session. Based on an initial patch by @johnlane.
Diffstat (limited to 'main.c')
-rw-r--r--main.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/main.c b/main.c
index 4bd55c3..0f9f459 100644
--- a/main.c
+++ b/main.c
@@ -56,6 +56,7 @@ usage()
" dtach -c <socket> <options> <command...>\n"
" dtach -n <socket> <options> <command...>\n"
" dtach -N <socket> <options> <command...>\n"
+ " dtach -p <socket>\n"
"Modes:\n"
" -a\t\tAttach to the specified socket.\n"
" -A\t\tAttach to the specified socket, or create it if it\n"
@@ -66,6 +67,8 @@ usage()
" -N\t\tCreate a new socket and run the specified command "
"detached,\n"
"\t\t and have dtach run in the foreground.\n"
+ " -p\t\tCopy the contents of standard input to the specified\n"
+ "\t\t socket.\n"
"Options:\n"
" -e <char>\tSet the detach character to <char>, defaults "
"to ^\\.\n"
@@ -106,7 +109,7 @@ main(int argc, char **argv)
if (mode == '?')
usage();
else if (mode != 'a' && mode != 'c' && mode != 'n' &&
- mode != 'A' && mode != 'N')
+ mode != 'A' && mode != 'N' && mode != 'p')
{
printf("%s: Invalid mode '-%c'\n", progname, mode);
printf("Try '%s --help' for more information.\n",
@@ -133,6 +136,19 @@ main(int argc, char **argv)
sockname = *argv;
++argv; --argc;
+ if (mode == 'p')
+ {
+ if (argc > 0)
+ {
+ printf("%s: Invalid number of arguments.\n",
+ progname);
+ printf("Try '%s --help' for more information.\n",
+ progname);
+ return 1;
+ }
+ return push_main();
+ }
+
while (argc >= 1 && **argv == '-')
{
char *p;