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

REGEX wildcards in NSH #2311

Open
patacongo opened this issue Feb 25, 2024 · 1 comment
Open

REGEX wildcards in NSH #2311

patacongo opened this issue Feb 25, 2024 · 1 comment

Comments

@patacongo
Copy link
Contributor

patacongo commented Feb 25, 2024

All NSH commands that accept a path name differ from the corresponding commands in other shells such as Bash in at least one important way:

  • Shells like Bash accept a REGEX pattern matching string. For example, rm dat*[0-9][.]log would delete all .log files in the current directory with names like dat_NNN_, where NNN is some decimal number. Another example, rm * would delete all non-hidden files in the current working directory (not strictly REGEX).

  • In NSH, the argument is the path to a file or directory.

This means the commands like rm * fail because * is not expanded into a list of file/directory names.

NSH has much of the look and feel these larger shells so any behavioral difference can be confusing. And sometimes there there is no simple alternative to the Bash-like command. There has been discussion recently, for example, on how to do rm * without *.

A solution would affect all NSH commands with path arguments. That would have to be reinterpreted as a REGEX match pattern and every file in the directory path would have to compared against the pattern and added to a list of paths to be operated on.

NOTE that arguments like *, ., and .. are not REGEX and might have to be handled in a different way.

@patacongo
Copy link
Contributor Author

A tiny REGEX is here: https://github.com/apache/nuttx/tree/master/libs/libc/regex

This has undergone a lot of changes; I am not sure how compatible the current version is.

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

1 participant