apache / nuttx-apps

Apache NuttX Apps is a collection of tools, shells, network utilities, libraries, interpreters and can be used with the NuttX RTOS
https://nuttx.apache.org/
Apache License 2.0
268 stars 504 forks source link

REGEX wildcards in NSH #2311

Open patacongo opened 5 months ago

patacongo commented 5 months ago

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:

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 commented 5 months ago

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.