Question

friends, in

gnu.getopt.Getopt.jar

there is some problem i am getting some problem when i am giving b* as option argument then it is taking as bin

Getopt g = new Getopt("cm_log_parser", args, "i:s"); //-D to enable debug log


while((opt = g.getopt()) != -1)
{
    switch (opt)
    {
        case 'f'://To set file name(if above is not specified)
            fileNameWithPath = getAndCheckOptArg(fFlag, opt, g);
            fFlag = true;
            break;

        case 'p'://To set the pattern
            String pattern = g.getOptarg();
            hFlag = true;
            break;

        case '?':
            usage("Invalid option" + opt + " option");
            break;
    }
}

When I specify -p "b*" it is returns bin , why this is happening?

Was it helpful?

Solution

The shell (I suspect you use Linux, right?) resolves the b* literal to bin (there must be a directory named bin in the current working directory), because it is treated as a wildcard.

Depending on the shell you use, you have to escape the asterisk... For example in bash, use

-p b\*

To escape it to be an asterisk instead of getting resolved by the shell

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top