pussuw commented on code in PR #1654:
URL: https://github.com/apache/nuttx-apps/pull/1654#discussion_r1143779202


##########
nshlib/nsh.h:
##########
@@ -715,6 +715,25 @@ struct nsh_parser_s
 #endif
 };
 
+#ifdef CONFIG_NSH_ALIAS
+struct nsh_alias_s
+{
+  FAR struct nsh_alias_s *next;    /* Single link list for traversing */
+  FAR char               *name;    /* Name of the alias */
+  FAR char               *value;   /* Value behind the name */
+  union
+  {
+    struct
+    {
+      uint8_t             exp : 1; /* Already expanded ? */

Review Comment:
   It is a POSIX requirement, a once expanded alias shall not be expanded again 
within a single tokenized string.
   
   ```
   $ alias foo=bar
   $ foo foo <- this will expand to bar foo
   ```
   
   The comment above is not correct. The recursive protection is against even 
more insane aliases that would really end in infinite recursion. LIke:
   
   ```
   $ alias echo=echo
   $ echo
   ```
   
   > To prevent infinite loops in recursive aliasing, if the shell is not 
currently processing an alias of the same name, the word shall be replaced by 
the value of the alias; otherwise, it shall not be replaced.
   
   
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_03_01



-- 
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

Reply via email to