pussuw commented on code in PR #1654: URL: https://github.com/apache/nuttx-apps/pull/1654#discussion_r1144621202
########## nshlib/nsh_parse.c: ########## @@ -115,6 +129,14 @@ struct nsh_memlist_s }; #endif +#ifdef CONFIG_NSH_ALIAS +struct nsh_alist_s +{ + int nallocs; + FAR struct nsh_alias_s *allocs[CONFIG_NSH_ALIAS_MAX_AMOUNT]; Review Comment: I thought of this as well, but it has side effects too. 1. The ordering of the aliases changes when pumping from one list to another. Although the significance of this is mostly cosmetic. 2. The corner case above would not work any more, as executing `$ ua ` would temporarily remove ua from the valid alias list (moving it to the expanded list). So all aliases *besides* ua would be removed. Another example: ``` $ alias foo='ls;unalias foo' $ foo ``` This would fail to perform the "unalias foo" part, as `foo` has been (temporarily) plucked from the list of known aliases (it cannot be found anymore). I know these corner cases are insane usages of aliases, but the standard does not prohibit making such aliases. I did explore other options for the separate NSH_ALIASLIST storage but all of them had some corner case that did not work. This implementation does at least work. There is also a clear benefit of NSH_ALIASLIST as it is declared from the stack and is valid only for a single command line at a time, no danger of propagating outside of the intended scope. https://github.com/apache/nuttx-apps/blob/482a24aaab723bd28338630182056a5ec7edfc11/nshlib/nsh_parse.c#L2473-L2477 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org