commandline session
$> 1 $echo hello > 1 $cat 1 hello $ls 1 $mv 1 2 $ls 2 $cat 2 hello $
http://pluto.infoclub.in/wp-content/uploads/2013/06/mv.c
code section
while ((c = getopt_long (argc, argv, "bfint:uvS:T", long_options, NULL))
!= -1)
{
switch (c)
{
case 'b':
make_backups = true;
if (optarg)
version_control_string = optarg;
break;
case 'f':
x.interactive = I_ALWAYS_YES;
break;
case 'i':
x.interactive = I_ASK_USER;
break;
case 'n':
x.interactive = I_ALWAYS_NO;
break;
case STRIP_TRAILING_SLASHES_OPTION:
remove_trailing_slashes = true;
break;
case 't':
if (target_directory)
error (EXIT_FAILURE, 0, _("multiple target directories specified"));
else
{
struct stat st;
if (stat (optarg, &st) != 0)
error (EXIT_FAILURE, errno, _("accessing %s"), quote (optarg));
if (! S_ISDIR (st.st_mode))
error (EXIT_FAILURE, 0, _("target %s is not a directory"),
quote (optarg));
}
target_directory = optarg;
break;
case 'T':
no_target_directory = true;
break;
case 'u':
x.update = true;
break;
case 'v':
x.verbose = true;
break;
case 'S':
make_backups = true;
backup_suffix_string = optarg;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
usage (EXIT_FAILURE);
}
}
http://stackoverflow.com/questions/10606250/macros-like-case-getopt-help-char-risky