On Thu, Aug 14, 2014 at 12:10:58PM -0400, Jared Yanovich wrote: > On Wed, Aug 13, 2014 at 07:41:08PM +0100, Jason McIntyre wrote: > > > the only thing i have to compare it with is bash: > > By no means comprehensive but: > > these appear to not include the current command: > zsh > FreeBSD ash > > these appear to include the current command: > AT&T ksh > bash > csh > tcsh > > From pdksh ChangeLog: > > Tue May 7 10:11:41 NDT 1996 Michael Rendell (mich...@panda.cs.mun.ca) > > * history.c(hist_get_newest,hist_get_oldest): > don't find the current (fc) command; removed print_err argument > (was always true). > > I am unable to find old pdksh sources to see if this patch is any better... >
the diff seems to work for me. i guess the question is if the user runs "fc -l", do they expect that most recent "fc -l" to show up in output. since it can effect calculations (what should `3k' produce, for example) i can;t see how it could not be expected. i've checked the posix docs for fc, but of course it's a bit hazy. it certainly doesn;t mention this issue explicitly. there is this: + If first and last are both omitted, the previous 16 commands shall be listed or the previous single command shall be edited (based on the -l option). that kind of suggests that the "fc -l" producing those "previous 16 commands" should not show up as part of them, but it's arguable. hmm. jmc > Index: history.c > =================================================================== > RCS file: /cvs/src/bin/ksh/history.c,v > retrieving revision 1.39 > diff -u -p -r1.39 history.c > --- history.c 19 May 2010 17:36:08 -0000 1.39 > +++ history.c 14 Aug 2014 15:43:38 -0000 > @@ -162,7 +162,7 @@ c_fc(char **wp) > if (!hfirst) > return 1; > /* can't fail if hfirst didn't fail */ > - hlast = hist_get_newest(false); > + hlast = hist_get_newest(true); > } else { > /* POSIX says not an error if first/last out of bounds > * when range is specified; at&t ksh and pdksh allow out of > @@ -173,7 +173,7 @@ c_fc(char **wp) > if (!hfirst) > return 1; > hlast = last ? hist_get(last, true, lflag ? true : false) : > - (lflag ? hist_get_newest(false) : hfirst); > + (lflag ? hist_get_newest(true) : hfirst); > if (!hlast) > return 1; > } >