Questions tagged [getopt-long]

Getopt::Long is a command line switch parsing library for Perl. For C-programming: The getopt and getopt_long functions automate some of the chores involved in parsing typical unix command line options.

The Getopt::Long Perl module is a parser for the POSIX command line switch syntax with GNU extensions. Both the traditional -s single character switches and the longer --longer switches are supported.

For C-programming: The getopt and getopt_long functions automate some of the chores involved in parsing typical unix command line options. For details, please see here.

190 questions
0
votes
1 answer

Invalid file path using getopt_long in C

I'm wondering why optarg returns an invalid path in the following case: --foo=~/.bashrc but not if I leave a space in between --foo ~/.bashrc. And what would be the workaround so it works on both cases. #include #include…
user1024718
  • 573
  • 6
  • 18
0
votes
1 answer

GetOpt Long recognizing Verbose

Right now, I'm trying to get my program to correctly regonize the flags i pass to it in the command line. The following commandline ./MineEscape --container BINARY infile.txt works correctly given that MineEscape is the name of the executable. …
James Wilks
  • 740
  • 1
  • 8
  • 20
0
votes
1 answer

different order of command line options in a command affecting my output

i am making a program in c that accepts command line arguments like --version , --download. when i do this : $program --version --download file the program outputs the version and downloads the file. But when i do this: $program --download…
0
votes
1 answer

How to use getopt-long in Chicken

How do I use getopt-long in Chicken? I've got the following code: (require 'getopt-long) (define grammar `((help (required #f) (value #f) (single-char #\h)) (limit (required #t) (value #f) ;; optional value …
Alexej Magura
  • 4,833
  • 3
  • 26
  • 40
0
votes
0 answers

getopt_long port to windows: __progname redefinition error

I'm using a port of getopt_long for windows which has the following lines: [...] static char * __progname __P((char *)); int getopt_internal __P((int, char * const *, const char *)); static char * __progname(nargv0) char * nargv0; { char *…
quimnuss
  • 1,503
  • 2
  • 17
  • 37
0
votes
1 answer

First value empty for options with multiple values in Perl Getopt::Long

could someone help me understanding why the bellow is happening. I am using Perl Getopt::Long to parse options with multiple values, but I am geting some strange results. The following code: #!/usr/bin/perl use warnings; use strict; use…
h.mon
  • 248
  • 2
  • 10
0
votes
1 answer

Perl Getopt::Long Assigning variable then going to subroutine

I have the following piece of code my $use = "Use: " . basename($0) . " [options]"; my $version = "Version: 0.1 \n"; my $variableA; my $variableB; GetOptions( 'a=s' => \$variableA, 'help' => sub { print $use; exit 0 }, 'version' …
yonetpkbji
  • 1,019
  • 2
  • 21
  • 35
0
votes
2 answers

getopt_long_only() not working

I need to check the following arguments: ./centro -n CD1 –cp 100000 –i 100000 –t 30 –s 1000 –p 11111 And they can come in any order. I have the following code: void checkParameters (int argc, char** argv, center_data* info) { int opt = 0; …
Alessandroempire
  • 1,640
  • 4
  • 31
  • 54
0
votes
1 answer

getopt_long long options work but not short options

Possible Duplicate: getopt_long() — proper way to use it? I'm struggling with getopt_long in my C program. Code: const struct option long_options[] = { { "help", 0, NULL, 'h' }, { "num", 1, NULL, 'n' }, { NULL, 0, NULL, 0 } }; do…
ale
  • 11,636
  • 27
  • 92
  • 149
0
votes
1 answer

getopt_long acting weirdly

I'm writing some code for parsing the command line input. The way I use getopt_long is as follows: int c = 0; static struct option long_options[] = { {"mode", 1, NULL, 'm'}, {"help", 0, NULL, 'h'}, {0, …
ljhljh235
  • 51
  • 1
  • 10
0
votes
1 answer

gengetopt: How to parse a string without an option (like a file name)

I'm trying to parse command line options using code generated by gengetopt, and I'm trying to figure out how to parse an extra argument (after all the other options) that has no long or short option. I'd like to call it like this: program [options]…
VerTiGo_Etrex
  • 139
  • 11
0
votes
1 answer

working with options in bash code

Possible Duplicate: Using getopts in bash shell script to get long and short command line options I'm trying to figure out how to make use of flag like -e/--email -h/--help for example. UPDATE: Current example: while getopts ":ec:h"…
Amanada Smith
  • 1,893
  • 9
  • 28
  • 42
0
votes
0 answers

How to write tests for getoptlong

I have written a small terminal application with objective-c on Mac that uses getoptlong to parse the command line arguments. The code that parses the command line is the following: + (void) parseCommandLine:(int) argc …
mandel
  • 2,921
  • 3
  • 23
  • 27
0
votes
1 answer

getopt_long doesnt handle my arguments right

int next_option; int keep_content =0; int option_index = 0; const string short_options = "c::"; const struct option long_options[] = { {"config", optional_argument, NULL, 'c'}, {"keep", no_argument, &keep_content, 1}, { NULL,0,…
sparky
  • 375
  • 6
  • 22
-1
votes
1 answer

Why does the GNU coding standard prefer getopt_long over argp?

I do not understand why the GNU Coding Standard has the following line in Section 4.2 - Writing Robust Programs Use getopt_long to decode arguments, unless the argument syntax makes this unreasonable. My understanding is that getopt is part of the…
1 2 3
12
13