Refine code to eliminate g_first_arrow_key in retrieve_hist_cmd()

g_first_arrow_key is a global variable. This can be passed from
caller as a parameter.