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

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

Reply via email to