diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-03-07 20:09:36 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-03-07 20:09:36 +0000 |
commit | 85659eeeb61570697044d6dc6617a8c6edb84049 (patch) | |
tree | f7767fddb777574a1fa22490a7ba2244edf553f4 /cpukit/libmisc/shell/main_cp.c | |
parent | 2008-03-07 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-85659eeeb61570697044d6dc6617a8c6edb84049.tar.bz2 |
2008-03-07 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/shell/main_cp.c, libmisc/shell/main_netstats.c,
libmisc/shell/shell_script.c: Add memset() of getopt_data to
ensure it is zeroed out each time we use getopt_r().
* libmisc/shell/shell.c: Do not echo commands if input is not a tty.
This makes the scripts behave more like UNIX scripts.
Diffstat (limited to 'cpukit/libmisc/shell/main_cp.c')
-rw-r--r-- | cpukit/libmisc/shell/main_cp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cpukit/libmisc/shell/main_cp.c b/cpukit/libmisc/shell/main_cp.c index 3812c3caac..7b48c47f71 100644 --- a/cpukit/libmisc/shell/main_cp.c +++ b/cpukit/libmisc/shell/main_cp.c @@ -65,6 +65,7 @@ __RCSID("$NetBSD: cp.c,v 1.39 2005/10/24 12:59:07 kleink Exp $"); #include <rtems.h> #include <rtems/shell.h> #include <rtems/shellconfig.h> +#include <getopt.h> #include <sys/param.h> #include <sys/stat.h> @@ -116,6 +117,7 @@ main_cp(rtems_shell_cp_globals* cp_globals, int argc, char *argv[]) enum op type; int Hflag, Lflag, Pflag, ch, fts_options, r; char *target; + struct getopt_data getopt_reent; to.p_end = to.p_path; to.target_end = empty; @@ -123,7 +125,9 @@ main_cp(rtems_shell_cp_globals* cp_globals, int argc, char *argv[]) (void)setlocale(LC_ALL, ""); Hflag = Lflag = Pflag = Rflag = 0; - while ((ch = getopt(argc, argv, "HLNPRfiprv")) != -1) + memset(&getopt_reent, 0, sizeof(getopt_data)); + + while ((ch = getopt_r(argc, argv, "HLNPRfiprv", &getopt_reent)) != -1) switch (ch) { case 'H': Hflag = 1; |