On Wed, 25 Sep 2013 18:15:51 +0200 Irek Szczesniak wrote: > On Wed, Sep 25, 2013 at 6:07 PM, Irek Szczesniak <[email protected]> > wrote: > > On Wed, Sep 25, 2013 at 5:59 PM, Glenn Fowler <[email protected]> wrote: > >> > >> On Wed, 25 Sep 2013 17:01:06 +0200 Irek Szczesniak wrote: > >>> On Wed, Sep 25, 2013 at 2:49 PM, Glenn Fowler <[email protected]> > >>> wrote: > >>> > > >>> > this is just a general comment on those contemplating adding > >>> > #ifdef to select option visibility based on the underlying system > >> > >>> Is this about md5sum(1)? AFAIK the *defaults* are platform-specific, > >>> based on what Windows does, but not the availability of the options. > >>> Or is this something different? > >> > >> md5sum triggered the comment > >> but there are / have been other patches in the queue that do similar this > >> libcmd::sync(1) and ksh93::cd(1) -@ come to mind > >> I wanted to nip it in the bud so it doesn't become a habit > >> > >> now re md5sum > >> > >> the gnu docs are fouled up because they don't match gnu-ish reality on > >> cygwin > >> cygwin actually gets it right by making --binary the default > >> but that leads to > >> gnu-md5sum *.tgz > gnu-output > >> run on linux and cygwin, for the same set of files, producing different > >> results > >> the md5sum (should) match but the cygwin output will have the '*' indicator > >> > >> suppose, for the same set of *.tgz you do this on cygwin > >> gnu-md5sum *.tgz > cygwin-output > >> and this on linux > >> gnu-md5sum *.tgz > linux-output > >> on cygwin this will fail > >> gnu-md5sum --check linux-output > >> at least on linux this will work > >> gnu-md5sum --check cygwin-output > >> > >> the *ast* --binary default is not platform specific because it is > >> consistent > >> across unix and _WINIX and honors the principle of least surprise > >> so this > >> ast-md5sum *.tgz > ast-output > >> and this > >> ast-md5sum --check ast-output > >> will work no matter what platform either command is executed on > >> > >> the next alpha, probably later today to fix the ASTAPI() build problem, > >> will > >> have libcmd::cksum(1) and libsum fixed to generate and consume the ' ' and > >> '*' > >> read mode indicators -- the only thing will be that on all systems by > >> default > >> ast md5sum will print the '*' indicator > > > > Why do you want to do that? > > > > On *LINUX* and Solaris 10 with /usr/gnu/bin/mdsum I get this: > > /usr/bin/md5sum /usr/bin/md5sum > > 85e85dcf910f4c5d1dd1729b2c81e584 /usr/bin/md5sum > > /usr/bin/md5sum --binary /usr/bin/md5sum > > 85e85dcf910f4c5d1dd1729b2c81e584 */usr/bin/md5sum > > > > This happens because --text and --binary are identical on Linux and Solaris. > >> -- lets see how many gnu-reliant scripts > >> blow up due to that -- this is one of those things that if you demand gnu > >> semantics on one side prepare to handle them on the other > > > > ... nothing to say here. I am not sure whether it is a good idea to > > serve us that mess GNU coreutils caused and force us to eat it, too. > > > > There may be a 3rd option: > > Use three states: > > 1. If --binary is given print " *" > > 2. If --text is given print " : > > 3. On UNIX/Linux default to " " if no option is given, and default to > > --text on Windows > >
> A coworker just reminded me why md5sum defaults to --text: As > originally conceived md5 and md5sum were created to create hashs over > mime headers, which use '\n' on UNIX/Linux but '\n\r' on Windows/DOS, > MIME, HTTP etc. So its not Windows which mandates this behaviour, its > the original design. --binary is optional for parsing MIME or HTTP > headers. > This is consistent with other md5 hash utility implementations like md5(1). thanks thats good to know but what possessed the gnu md5sum *file* utility developers to force mime header semantics on files when all other unix sum *file* utilities do not make that distinction is there an option to gnu-md5sum to just process a mime/HTPP header? nope so any code that wants to use the md5sum file utility to sum a mime header already has to do special processing to extract the header from the rest of the stream they might as well add the --text option at that point AHA (it really was an aha just at this moment) thanks to you and your coworker I realize why I'm being so insistent on this in ast md5sum --text means \r\n => \n *on all platforms* in ast this just works in unix and _WINIX $ printf $'aha\r\n' | md5sum --text c6409a1abd80c82df3c71bb00f2d1b64 $ printf $'aha\n' | md5sum --text c6409a1abd80c82df3c71bb00f2d1b64 $ printf $'aha\n' | md5sum c6409a1abd80c82df3c71bb00f2d1b64 now try to do that with gnu md5sum or for a real world example collect MIME HTTP etc. data with \r\n and try to process it as text on linux with gnu-md5sum and here's *another* case where it would have been much much better to discuss a problem on the list before posting a patch; in this case defaulting ast cksum to --text would have been wrong for unix and _WINIX _______________________________________________ ast-developers mailing list [email protected] http://lists.research.att.com/mailman/listinfo/ast-developers
