6.46 Gzip-1.3.5

Iman Darabi iman.darabi at gmail.com
Fri Oct 28 09:49:11 PDT 2005


> The gzip command behaves differently depending on how it is called;
> I would guess it just looks at the arguments passed to main(*).  I
> did a little experimenting, and it seems if it is invoked with any
> name except 'gunzip' it compresses, and if it is invoked as 'gunzip'
> then it decompresses.
>
> Mike

oh , yes Mike , you are right . found these code in gzip.c file line 474 :

#ifndef GNU_STANDARD
    /* For compatibility with old compress, use program name as an option.
     * If you compile with -DGNU_STANDARD, this program will behave as
     * gzip even if it is invoked under the name gunzip or zcat.
     *
     * Systems which do not support links can still use -d or -dc.
     * Ignore an .exe extension for MSDOS, OS/2 and VMS.
     */
    if (  strncmp(progname, "un",  2) == 0     /* ungzip, uncompress */
       || strncmp(progname, "gun", 3) == 0) {  /* gunzip */
        decompress = 1;
    } else if (strequ(progname+1, "cat")       /* zcat, pcat, gcat */
            || strequ(progname, "gzcat")) {    /* gzcat */
        decompress = to_stdout = 1;
    }

thanks Mike .



More information about the lfs-support mailing list