Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minus symbol stripped from negative numbers by console component (IDFGH-9497) #10857

Closed
3 tasks done
tadejg opened this issue Feb 27, 2023 · 2 comments
Closed
3 tasks done

Comments

@tadejg
Copy link

tadejg commented Feb 27, 2023

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

I have setup a REPL following the basic console example. For one of my commands, I want to accept negative numbers as the value. The command looks like this: set <key> <value>. When I run the command as set some_key -5 I get the following error set: invalid option "-?". I have tried escaping the - which worked, but made the number positive.

repl> set some_key \-5
I (81716) repl: Updating value to 5

I also tried wrapping the value in quotes and double escaping the - symbol with no better results.

repl> set some_key \\-5
I (199946) repl: Updating value to \-5
repl> set some_key "-5"
set: invalid option "-?"
Command returned non-zero error code: 0x1 (ERROR)
repl> set some_key "\-5"
I (224686) repl: Updating value to 5

The only way I was able to get this working was by following the cmd_nvs component from the advanced console example where the value is passed after -v or --value.

repl> set some_key -v -3
I (17196) repl: Updating value to -3

This time it worked without having to escape anything. I can use this as a workaround for the time being, but would prefer to drop the -v since you're always expected to pass a value to the set command anyways.

The only difference in code was with the args definition:

// Doesn't work
static struct {
    struct arg_str *key = arg_str1(NULL, NULL, "<key>", "Key to update");
    struct arg_str *value = arg_str1(NULL, NULL, "<value>", "Value to set");
    struct arg_end *end = arg_end(2);
} setArgs;


// Works
static struct {
    struct arg_str *key = arg_str1(NULL, NULL, "<key>", "Key to update");
    struct arg_str *value = arg_str1("v", "value", "<value>", "Value to set");  // This line changed
    struct arg_end *end = arg_end(2);
} setArgs;
@github-actions github-actions bot changed the title Minus symbol stripped from negative numbers by console component Minus symbol stripped from negative numbers by console component (IDFGH-9497) Feb 27, 2023
@igrr
Copy link
Member

igrr commented Feb 27, 2023

@tadejg Since the behavior is the same with argtable3 on Linux (reproducer), I would recommend reporting this upstream at https://github.com/argtable/argtable3/issues. If this issue is fixed upstream, we will update argtable3 to the latest release version.

@tadejg
Copy link
Author

tadejg commented Feb 27, 2023

Understood, will report it upstream then, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants