From owner-freebsd-questions Wed Sep 20 18:31:22 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mail.inka.de (quechua.inka.de [212.227.14.2]) by hub.freebsd.org (Postfix) with ESMTP id 6836637B423 for ; Wed, 20 Sep 2000 18:31:18 -0700 (PDT) Received: from ganerc.mips.inka.de (uucp@) by mail.inka.de with local-bsmtp id 13bvCn-0001z2-00; Thu, 21 Sep 2000 03:31:17 +0200 Received: (from daemon@localhost) by ganerc.mips.inka.de (8.11.0/8.11.0) id e8L0h3T66681 for freebsd-questions@freebsd.org; Thu, 21 Sep 2000 02:43:03 +0200 (CEST) (envelope-from daemon) From: naddy@mips.inka.de (Christian Weisgerber) Subject: Re: GNU tar on FreeBSD Date: 21 Sep 2000 02:43:03 +0200 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> To: freebsd-questions@freebsd.org Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Igor Roboul 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