Date: 21 Sep 2000 02:43:03 +0200 From: naddy@mips.inka.de (Christian Weisgerber) To: freebsd-questions@freebsd.org Subject: Re: GNU tar on FreeBSD Message-ID: <8qblin$213g$1@ganerc.mips.inka.de> References: <20000920080632.A11387@linux.rainbow> <20000920100425.A14928@linux.rainbow> <20000919233308.R367@149.211.6.64.reflexcom.com> <20000920105741.F14928@linux.rainbow>
next in thread | previous in thread | raw e-mail | index | archive | help
Igor Roboul <igorr@crosswinds.net> wrote: > > You cannot mix the "dashless" syntax with dashed options willy-nilly. > Ok, thank you. > But with Linux I can. I think there is some differences between > getopt() in glibc and getopt() in BSD libc. FreeBSD's in-tree tar has significantly diverged from the version currently distributed by the GNU project and typically found on Linux distributions. getopt() doesn't really enter the picture. Pretty much every tar out there supports both the traditional dashless syntax and the unix standard one with options introduced by '-'. getopt() can only parse the latter. The traditional syntax requires separate parsing or internal rewriting to standard syntax. Mixing both syntaxes can give surprising results, as you noticed. I strongly advise against it. The traditional syntax for what you were trying to accomplish is this: ... | tar czTf - output.tar.gz The first argument contains all the bundled options. Arguments to any of these options are taken in order from the subsequent arguments. argv[0] tar argv[1] c command: create, no argument z option: compress, no argument T option: input file list, will take argument 2 f option: archive file, will take argument 3 argv[2] - argument for first option to require one argv[3] output.tar.gz argument for second option to require one Reordering options requires reordering of the arguments, e.g.: ... | tar cfzT output.tar.gz - -- Christian "naddy" Weisgerber naddy@mips.inka.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8qblin$213g$1>