Fix: `help': support recursive ghosts; go.c: fix self-recursion detection..
commit6f20c631e1856cbff3e2fd91358b4e4b999f78fd
authorSteffen Nurpmeso <steffen@sdaoden.eu>
Mon, 19 Mar 2018 17:43:59 +0000 (19 18:43 +0100)
committerSteffen Nurpmeso <steffen@sdaoden.eu>
Sat, 24 Mar 2018 23:49:38 +0000 (25 00:49 +0100)
tree492747caa8cd31d664762d90e98f0fc56d8ffab2
parent195a62b4a3af18d945c585f456e3959f639d8b82
Fix: `help': support recursive ghosts; go.c: fix self-recursion detection..

The latter was false for something like

  commandalias x q; commandalias q echo au

since the q became expanded to `quit' due to falsely detected
self-recursion (alias expansion equalsnew command word).

On the other hand

  help x

would have falsely claimed that x called `quit', because no
recursion evaluation did happen.  Well, in the given example it
does indeed...

Do implement an identical algorithm for `help' and in
a_go_evaluate(): allow one level of expansion with identical
names, but stop expanding commandaliases thereafter, e.g.,

  commandalias q q; commandalias x q; x

will now be evaluated as

  x -> q -> q -> quit

as can be seen

  #?0!0/NONE[#/var/spool/mail/steffen]? commandalias q q
  #?0!0/NONE[#/var/spool/mail/steffen]? commandalias x q
  #?0!0/NONE[#/var/spool/mail/steffen]? ?x
  x -> q -> q (quit): Exit session with [<status>], saving messages as necessary
  #?0!0/NONE[#/var/spool/mail/steffen]? x
  ALI (null) word x
  RESTART 1 <q>
  ALI q word q
  RESTART 1 <q>
  NOT LOOKING ALIAS FOR q
  ALI (null) word unbind
  ELSE not found <unbind>
  #?0[steffen@essex nail.git]$
cc-test.sh
cmd-tab.c
go.c