Sujet : Re: Rationale for aligning data on even bytes in a Unix shell file?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 09. May 2025, 03:56:24
Autres entêtes
Organisation : None to speak of
Message-ID : <874ixucx0n.fsf@nosuchdomain.example.com>
References : 1
User-Agent : Gnus/5.13 (Gnus v5.13)
Janis Papanagnou <janis_papanagnou+
ng@hotmail.com> writes:
In a "C" file (of the Kornshell software) I stumbled across this
comment: "Each command in the history file starts on an even byte
and is null-terminated."
>
I wonder what's the reason behind that even-byte-alignment, on "C"
level or on Unix/files level. Any ideas?
>
Janis
>
Note: Since it's not a shell question but more of a programming or
platform related question I try to get the answer here (and not in
comp.unix.shell); just saying to prevent distracting calls to order.
This question led to a number of long digressions, most of which didn't
address the original question.
The quoted comment is in src/cmd/ksh93/edit/history.c in
<
https://github.com/ksh93/ksh>. It goes on to mention versions 0
and 1 of the history file format.
I haven't been able to find sources for ksh that would shed any light on
this.
The even byte requirement in version 1 was likely inherited from version
0. The initial commit in the git repo includes release notes going back
to 1987, but no old versions of the source code.
My best guess is that the author of some early version of ksh, when
first defining the Version 0 history file format, just thought that even
byte alignment was a good idea at the time. There might not be any
deeper reason than that.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */