Closed gitboy closed 2 weeks ago
Discussed offline. The getcommand
function uses that switch statement to mitigate infinite recursion caused by inadvertently executing the history program as a result of matching a command. The /
is meant to protect full- and relative-pathname expressions of the history command (e.g., ./--
) but it goes overboard by applying the rule after whitespace is trimmed. I think there is some room for improvement here, and I'll likely make a fix.
This code shows its age, esp. wrt the lack of unit testing.
I occasionally come across the following oddness using the history mechanism in rc, where we link
./-, ./--, ./-p, ./--p
to thehistory
binary. I have found on occasion that despite matching lines in my $history existing the program refuses to find them when I search.I've contrived an example to demonstrate;
It seems related to the the getcommand() function; when I comment the following
I obtain the expected behaviour;
It seems this is due to the history program trying to avoid including its own invocations when searching back through the shell $history. Can anyone improve this so that we can search shell history with confidence? (please don't suggest readline)