diff options
| author | Ned T. Crigler <crigler@users.sourceforge.net> | 2015-07-18 13:13:09 -0700 |
|---|---|---|
| committer | Ned T. Crigler <crigler@users.sourceforge.net> | 2015-07-18 13:13:09 -0700 |
| commit | 087e89f7a8fecba3e8d276ab9808f10e6077784b (patch) | |
| tree | 7c0e6148ec590c989632416031711437b1e626bb /main.c | |
| parent | b7d5154c18cb57dd5680114315fbc4175cf1ea26 (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.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -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; |
