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

nshlib: add expr command support #2268

Merged
merged 1 commit into from
Jan 26, 2024
Merged

nshlib: add expr command support #2268

merged 1 commit into from
Jan 26, 2024

Conversation

Junbo-Zheng
Copy link
Contributor

Summary

nshlib: add expr command support

It is a mini version for the expr command, which implements the features of addition, subtraction, multiplication, division and mod.

Reference: https://www.geeksforgeeks.org/expr-command-in-linux-with-examples/

Signed-off-by: Junbo Zheng [email protected]

Impact

Testing

bl2> expr 5 - 2
3
bl2> set hello 10
bl2> expr $hello - 2
8
bl2> expr 8 a 9
Unknown operator
bl2> expr 20 / 5
4
bl2> expr 10 % 4
2
bl2> expr 10 / 0
operand2 invalid
bl2>
bl2> expr 100 + 0
100

It is a mini version for the `expr` command, which implements the features of addition, subtraction, multiplication, division and mod.

Reference: https://www.geeksforgeeks.org/expr-command-in-linux-with-examples/

bl2>
bl2> expr 1 + 2
3
bl2> expr
Usage: expr <operand1> <operator> <operand2>
bl2> expr 5 - 2
3
bl2> set hello 10
bl2> expr $hello - 2
8
bl2> expr 8 a 9
Unknown operator
bl2> expr 20 / 5
4
bl2> expr 10 % 4
2
bl2> expr 10 / 0
operand2 invalid
bl2>
bl2> expr mi + 100
invalid parameter
bl2> expr 100 + mi
invalid parameter
bl2> expr 100 + 0
100

Signed-off-by: Junbo Zheng <[email protected]>
@xiaoxiang781216 xiaoxiang781216 merged commit c699b05 into apache:master Jan 26, 2024
25 checks passed
@Junbo-Zheng Junbo-Zheng deleted the nshlib branch January 26, 2024 09:14
xiaoxiang781216 pushed a commit to apache/nuttx that referenced this pull request Jan 29, 2024
freakishness pushed a commit to freakishness/incubator-nuttx that referenced this pull request Feb 18, 2024
halyssonJr pushed a commit to halyssonJr/nuttx that referenced this pull request Apr 10, 2024
anchao pushed a commit to anchao/nuttx that referenced this pull request Sep 6, 2024
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

Successfully merging this pull request may close these issues.

2 participants