From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 20 12:46:29 2013 Received: (at submit) by debbugs.gnu.org; 20 Sep 2013 16:46:29 +0000 Received: from localhost ([127.0.0.1]:51538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VN3qf-0002SL-8S for submit@debbugs.gnu.org; Fri, 20 Sep 2013 12:46:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45311) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VN3qc-0002S7-4W for submit@debbugs.gnu.org; Fri, 20 Sep 2013 12:46:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VN3qN-0004uj-U3 for submit@debbugs.gnu.org; Fri, 20 Sep 2013 12:46:20 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:45110) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN3qN-0004ud-RH for submit@debbugs.gnu.org; Fri, 20 Sep 2013 12:46:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN3qF-0007ti-8F for bug-coreutils@gnu.org; Fri, 20 Sep 2013 12:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VN3q3-0004pS-Iv for bug-coreutils@gnu.org; Fri, 20 Sep 2013 12:46:03 -0400 Received: from mail-yh0-x236.google.com ([2607:f8b0:4002:c01::236]:59303) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN3q3-0004pD-EV for bug-coreutils@gnu.org; Fri, 20 Sep 2013 12:45:51 -0400 Received: by mail-yh0-f54.google.com with SMTP id z20so246879yhz.41 for ; Fri, 20 Sep 2013 09:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=U6IzZMhOZj87G9x4HNamCgK2X1OhmbzHWC5wkjMFw/Y=; b=mHPFlNZa4Jl6S/oTk5yCmwipNlUI9whlFJWwUZRSYVId2o7bxD8Y9T1JaKLFdwLODK nIImSrhsqVktFgYnAcW+9mvz4xHh+4tYISTYDkIaVTJQQJ/ff3Lm8ZzLsTJLSJUY0i9V +OvN5TJi2nCbtNx0Oy0/T64kejsgJLdN2f3/7X5FyvFU6HXvtF46pmS0kx7NYst0Vzxw ha4WWSURT8jYPFepMuHScLSBf2olJYbs28IT+iRKp8qk2xSG7mNx5v/fJaUfmHik802U whm7As7SO1oohp58st3c3pp3cmKmGJ+cm0y3VtCm2saNuhtGM5Zq++Ml9DtXbl/jc3N7 lhmg== X-Received: by 10.236.184.41 with SMTP id r29mr1506446yhm.74.1379695550157; Fri, 20 Sep 2013 09:45:50 -0700 (PDT) Received: from [172.16.1.108] ([207.34.115.66]) by mx.google.com with ESMTPSA id u52sm19237256yhg.5.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Sep 2013 09:45:49 -0700 (PDT) Message-ID: <523C7CD1.1090907@gmail.com> Date: Fri, 20 Sep 2013 10:50:25 -0600 From: Assaf Gordon User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130821 Icedove/17.0.8 MIME-Version: 1.0 To: bug-coreutils@gnu.org Subject: mktemp - conflicting options affected by ENV Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hello, Not sure if this is a bug or just unintended side-effect, but it caused some scripts here to fail and took a while to troubleshoot: It basically boils down to the interplay between the deprecated "-t" "-p" and "$TMPDIR" and "--tmpdir". === ## ## Problem 1: "-t" and TMPDIR (if non-empty) overrides "--tmpdir" ## $ TMPDIR= mktemp -u --tmpdir=. -t XXXXXX ./og9G5s $ TMPDIR=/foo/ mktemp -u --tmpdir=. -t XXXXXX /foo/AAWcOl ## ## Problem 2: if TMPDIR is empty, "--tmpdir" overrides "-p", despite having "-t" ## $ TMPDIR=/foo/ mktemp -u -p /bar/ --tmpdir=. -t XXXXXX /foo/tHXcrq $ TMPDIR= mktemp -u -p /bar/ --tmpdir=. -t XXXXXX ./OfWXSS ## I'd expect the above to use "/bar/OfWXSS", to be consistent with TMPDIR overriding "--tmpdir". === I realize "-t" and "-p" are deprecated, and it's best not to meddle with them - but for consistency, perhaps consider having the new "--tmpdir" always take precedence over "-t" and "-p" ? or print a warning to STDERR when "-t" and "--tmpdir" are mixed? Regards, -gordon From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 20 20:14:33 2013 Received: (at 15425) by debbugs.gnu.org; 21 Sep 2013 00:14:33 +0000 Received: from localhost ([127.0.0.1]:52154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VNAqH-000650-1g for submit@debbugs.gnu.org; Fri, 20 Sep 2013 20:14:33 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]:19755) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VNAqE-00064l-T0 for 15425@debbugs.gnu.org; Fri, 20 Sep 2013 20:14:31 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAJjkPFJtTJVE/2dsb2JhbAANTcJqgwaBMYMZAQEBAwEyAUYFCwsNCwkWDwkDAgECAUUGDQEHAQGHe6gHkxWPMjMHhB4DlB+KNY5D Received: from unknown (HELO [192.168.1.79]) ([109.76.149.68]) by mail3.vodafone.ie with ESMTP; 21 Sep 2013 01:14:25 +0100 Message-ID: <523CE4DF.7030106@draigBrady.com> Date: Sat, 21 Sep 2013 01:14:23 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Assaf Gordon Subject: Re: bug#15425: mktemp - conflicting options affected by ENV References: <523C7CD1.1090907@gmail.com> In-Reply-To: <523C7CD1.1090907@gmail.com> X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15425 Cc: 15425@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 09/20/2013 05:50 PM, Assaf Gordon wrote: > Hello, > > Not sure if this is a bug or just unintended side-effect, but it caused some scripts here to fail and took a while to troubleshoot: > It basically boils down to the interplay between the deprecated "-t" "-p" and "$TMPDIR" and "--tmpdir". > > === > ## > ## Problem 1: "-t" and TMPDIR (if non-empty) overrides "--tmpdir" > ## > $ TMPDIR= mktemp -u --tmpdir=. -t XXXXXX > ./og9G5s > $ TMPDIR=/foo/ mktemp -u --tmpdir=. -t XXXXXX > /foo/AAWcOl Yes this is confusing, and _not_ order dependent: $ TMPDIR=/foo/ mktemp -t -u --tmpdir=. XXXXXX /foo/AAWcOl > > ## > ## Problem 2: if TMPDIR is empty, "--tmpdir" overrides "-p", despite having "-t" > ## > $ TMPDIR=/foo/ mktemp -u -p /bar/ --tmpdir=. -t XXXXXX > /foo/tHXcrq > $ TMPDIR= mktemp -u -p /bar/ --tmpdir=. -t XXXXXX > ./OfWXSS > ## I'd expect the above to use "/bar/OfWXSS", to be consistent with TMPDIR overriding "--tmpdir". > === Also confusing, and order dependent too: $ mktemp -p /aaa -u --tmpdir=. asdf/XXXX ./asdf/wdIT $ mktemp -u --tmpdir=. -p /aaa asdf/XXXX /aaa/asdf/3Jc7 > I realize "-t" and "-p" are deprecated, and it's best not to meddle with them - > but for consistency, perhaps consider having the new "--tmpdir" always take precedence over "-t" and "-p" ? > or print a warning to STDERR when "-t" and "--tmpdir" are mixed? Yes I agree that --tmpdir should override -pt no matter what the order. In fact there is no reason to use -pt with --tmpdir and since the former are deprecated, I suggest we just disallow that combination with an error. Patch coming up. thanks! Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 20 20:40:40 2013 Received: (at 15425) by debbugs.gnu.org; 21 Sep 2013 00:40:40 +0000 Received: from localhost ([127.0.0.1]:52181 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VNBFW-0006j3-HO for submit@debbugs.gnu.org; Fri, 20 Sep 2013 20:40:39 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]:43359) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VNBFS-0006ij-3S for 15425@debbugs.gnu.org; Fri, 20 Sep 2013 20:40:34 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBADvqPFJtTJVE/2dsb2JhbAANTcJqgwaBMYMZAQEBBDIBRhALDQsJFg8JAwIBAgFFBg0BBwEBsASTFY8yMweEHgOUH4o1jkM Received: from unknown (HELO [192.168.1.79]) ([109.76.149.68]) by mail3.vodafone.ie with ESMTP; 21 Sep 2013 01:40:28 +0100 Message-ID: <523CEAFB.3060102@draigBrady.com> Date: Sat, 21 Sep 2013 01:40:27 +0100 From: =?windows-1252?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Assaf Gordon Subject: Re: bug#15425: mktemp - conflicting options affected by ENV References: <523C7CD1.1090907@gmail.com> <523CE4DF.7030106@draigBrady.com> In-Reply-To: <523CE4DF.7030106@draigBrady.com> X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15425 Cc: 15425@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 09/21/2013 01:14 AM, Pádraig Brady wrote: > On 09/20/2013 05:50 PM, Assaf Gordon wrote: >> Hello, >> >> Not sure if this is a bug or just unintended side-effect, but it caused some scripts here to fail and took a while to troubleshoot: >> It basically boils down to the interplay between the deprecated "-t" "-p" and "$TMPDIR" and "--tmpdir". >> >> === >> ## >> ## Problem 1: "-t" and TMPDIR (if non-empty) overrides "--tmpdir" >> ## >> $ TMPDIR= mktemp -u --tmpdir=. -t XXXXXX >> ./og9G5s >> $ TMPDIR=/foo/ mktemp -u --tmpdir=. -t XXXXXX >> /foo/AAWcOl > > Yes this is confusing, and _not_ order dependent: > > $ TMPDIR=/foo/ mktemp -t -u --tmpdir=. XXXXXX > /foo/AAWcOl > >> >> ## >> ## Problem 2: if TMPDIR is empty, "--tmpdir" overrides "-p", despite having "-t" >> ## >> $ TMPDIR=/foo/ mktemp -u -p /bar/ --tmpdir=. -t XXXXXX >> /foo/tHXcrq >> $ TMPDIR= mktemp -u -p /bar/ --tmpdir=. -t XXXXXX >> ./OfWXSS >> ## I'd expect the above to use "/bar/OfWXSS", to be consistent with TMPDIR overriding "--tmpdir". >> === > > Also confusing, and order dependent too: > > $ mktemp -p /aaa -u --tmpdir=. asdf/XXXX > ./asdf/wdIT > $ mktemp -u --tmpdir=. -p /aaa asdf/XXXX > /aaa/asdf/3Jc7 > >> I realize "-t" and "-p" are deprecated, and it's best not to meddle with them - >> but for consistency, perhaps consider having the new "--tmpdir" always take precedence over "-t" and "-p" ? >> or print a warning to STDERR when "-t" and "--tmpdir" are mixed? > > Yes I agree that --tmpdir should override -pt no matter what the order. > In fact there is no reason to use -pt with --tmpdir and since the former > are deprecated, I suggest we just disallow that combination with an error. > > Patch coming up. I also see the --help says that -p implies -t AFAICS -t in the context of -p just means to interpret template as a single file without dirs, however the example below shows that -t is not in fact implied with -p $ mktemp -u -p dir1 dir2/XXXXXX dir1/dir2/qQBdsf $ mktemp -u -t -p dir1 dir2/XXXXXX src/mktemp: invalid template, ‘dir2/XXXXXX’, contains directory separator So rather than adjusting any functionality of these deprecated options, I'll just remove the --help text saying that -t is implied. thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 20 22:44:46 2013 Received: (at 15425-done) by debbugs.gnu.org; 21 Sep 2013 02:44:46 +0000 Received: from localhost ([127.0.0.1]:52344 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VNDBc-0001EE-Rs for submit@debbugs.gnu.org; Fri, 20 Sep 2013 22:44:45 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]:42212) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VNDBW-0001Dw-S5 for 15425-done@debbugs.gnu.org; Fri, 20 Sep 2013 22:44:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsEBAMAHPVJtTh+W/2dsb2JhbAANTYM/TIkMuFeBMYMZAQEBAwFHMgULCw0EAwECAQkWDwkDAgECAT0IBgoDAQUCAQEWh2UNqAeEf44Xj1QMBQcJhBUDkCaDeYUMhSmFbohV Received: from unknown (HELO [192.168.1.79]) ([109.78.31.150]) by mail3.vodafone.ie with ESMTP; 21 Sep 2013 03:44:05 +0100 Message-ID: <523D07F5.6060708@draigBrady.com> Date: Sat, 21 Sep 2013 03:44:05 +0100 From: =?windows-1252?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Assaf Gordon Subject: Re: bug#15425: mktemp - conflicting options affected by ENV References: <523C7CD1.1090907@gmail.com> <523CE4DF.7030106@draigBrady.com> <523CEAFB.3060102@draigBrady.com> In-Reply-To: <523CEAFB.3060102@draigBrady.com> X-Enigmail-Version: 1.5.2 Content-Type: multipart/mixed; boundary="------------010604050106040402000606" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15425-done Cc: 15425-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------010604050106040402000606 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit On 09/21/2013 01:40 AM, Pádraig Brady wrote: > On 09/21/2013 01:14 AM, Pádraig Brady wrote: >> On 09/20/2013 05:50 PM, Assaf Gordon wrote: >>> Hello, >>> >>> Not sure if this is a bug or just unintended side-effect, but it caused some scripts here to fail and took a while to troubleshoot: >>> It basically boils down to the interplay between the deprecated "-t" "-p" and "$TMPDIR" and "--tmpdir". >>> >>> === >>> ## >>> ## Problem 1: "-t" and TMPDIR (if non-empty) overrides "--tmpdir" >>> ## >>> $ TMPDIR= mktemp -u --tmpdir=. -t XXXXXX >>> ./og9G5s >>> $ TMPDIR=/foo/ mktemp -u --tmpdir=. -t XXXXXX >>> /foo/AAWcOl >> >> Yes this is confusing, and _not_ order dependent: >> >> $ TMPDIR=/foo/ mktemp -t -u --tmpdir=. XXXXXX >> /foo/AAWcOl >> >>> >>> ## >>> ## Problem 2: if TMPDIR is empty, "--tmpdir" overrides "-p", despite having "-t" >>> ## >>> $ TMPDIR=/foo/ mktemp -u -p /bar/ --tmpdir=. -t XXXXXX >>> /foo/tHXcrq >>> $ TMPDIR= mktemp -u -p /bar/ --tmpdir=. -t XXXXXX >>> ./OfWXSS >>> ## I'd expect the above to use "/bar/OfWXSS", to be consistent with TMPDIR overriding "--tmpdir". >>> === >> >> Also confusing, and order dependent too: >> >> $ mktemp -p /aaa -u --tmpdir=. asdf/XXXX >> ./asdf/wdIT >> $ mktemp -u --tmpdir=. -p /aaa asdf/XXXX >> /aaa/asdf/3Jc7 >> >>> I realize "-t" and "-p" are deprecated, and it's best not to meddle with them - >>> but for consistency, perhaps consider having the new "--tmpdir" always take precedence over "-t" and "-p" ? >>> or print a warning to STDERR when "-t" and "--tmpdir" are mixed? >> >> Yes I agree that --tmpdir should override -pt no matter what the order. >> In fact there is no reason to use -pt with --tmpdir and since the former >> are deprecated, I suggest we just disallow that combination with an error. >> >> Patch coming up. > > I also see the --help says that -p implies -t > AFAICS -t in the context of -p just means to interpret template as a single file without dirs, > however the example below shows that -t is not in fact implied with -p > > $ mktemp -u -p dir1 dir2/XXXXXX > dir1/dir2/qQBdsf > $ mktemp -u -t -p dir1 dir2/XXXXXX > src/mktemp: invalid template, ‘dir2/XXXXXX’, contains directory separator > > So rather than adjusting any functionality of these deprecated options, > I'll just remove the --help text saying that -t is implied. Which would make -p = --tmpdir, which is what the code has done since being introduced to coreutils 6 years ago, and what the texinfo has documented for the last 4 years. So I've just aligned the --help to say -p is the short form of --tmpdir. Hopefully the attached addresses all these issues. thanks, Pádraig. --------------010604050106040402000606 Content-Type: text/x-patch; name="mktemp-pt.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mktemp-pt.patch" >From 53e0ce82ddd47e0d166742426c91d9b8473b8006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sat, 21 Sep 2013 03:33:12 +0100 Subject: [PATCH] mktemp: disallow deprecated -t with --tempdir * doc/coreutils.texi (mktemp invocation): Clarify that _all_ error messages are suppressed with the -q option. * src/mktemp.c (usage): Synchronize the -p option description with the logic and info docs. I.E. that -p is just an alias of --tmpdir. (main): Disallow the deprecated -t option in combination with --tmpdir, which would result in -t getting precedence. * tests/misc/mktemp.pl: Add a test case. * NEWS: Mention the change in behavior. Fixes http://bugs.gnu.org/154245 --- NEWS | 2 ++ doc/coreutils.texi | 5 +++-- src/mktemp.c | 21 +++++++++++---------- tests/misc/mktemp.pl | 5 +++++ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index d26722d..4855475 100644 --- a/NEWS +++ b/NEWS @@ -65,6 +65,8 @@ GNU coreutils NEWS -*- outline -*- dd status=none now suppresses all non fatal diagnostic messages, not just the transfer counts. + mktemp now disallows using the deprecated -t option along with --tmpdir. + stdbuf now requires at least one buffering mode option to be specified, as per the documented interface. diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 21216b4..f2eba72 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -13421,8 +13421,9 @@ umask is more restrictive. @itemx --quiet @opindex -q @opindex --quiet -Suppress diagnostics about failure to create a file or directory. The -exit status will still reflect whether a file was created. +Suppress all error messages, including command option syntax errors, +and failure to create a file or directory. +The exit status will still reflect whether a file was created. @item -u @itemx --dry-run diff --git a/src/mktemp.c b/src/mktemp.c index 44845c3..bb0e8c1 100644 --- a/src/mktemp.c +++ b/src/mktemp.c @@ -43,7 +43,6 @@ static const char *default_template = "tmp.XXXXXXXXXX"; enum { SUFFIX_OPTION = CHAR_MAX + 1, - TMPDIR_OPTION }; static struct option const longopts[] = @@ -52,7 +51,7 @@ static struct option const longopts[] = {"quiet", no_argument, NULL, 'q'}, {"dry-run", no_argument, NULL, 'u'}, {"suffix", required_argument, NULL, SUFFIX_OPTION}, - {"tmpdir", optional_argument, NULL, TMPDIR_OPTION}, + {"tmpdir", optional_argument, NULL, 'p'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} @@ -78,14 +77,14 @@ Files are created u+rw, and directories u+rwx, minus umask restrictions.\n\ fputs (_("\ -d, --directory create a directory, not a file\n\ -u, --dry-run do not create anything; merely print a name (unsafe)\n\ - -q, --quiet suppress diagnostics about file/dir-creation failure\n\ + -q, --quiet suppress all error messages\n\ "), stdout); fputs (_("\ --suffix=SUFF append SUFF to TEMPLATE; SUFF must not contain a slash.\n\ This option is implied if TEMPLATE does not end in X\n\ "), stdout); fputs (_("\ - --tmpdir[=DIR] interpret TEMPLATE relative to DIR; if DIR is not\n\ + -p DIR, --tmpdir[=DIR] interpret TEMPLATE relative to DIR; if DIR is not\n\ specified, use $TMPDIR if set, else /tmp. With\n\ this option, TEMPLATE must not be an absolute name;\n\ unlike with -t, TEMPLATE may contain slashes, but\n\ @@ -93,7 +92,6 @@ Files are created u+rw, and directories u+rwx, minus umask restrictions.\n\ "), stdout); fputs ("\n", stdout); fputs (_("\ - -p DIR use DIR as a prefix; implies -t [deprecated]\n\ -t interpret TEMPLATE as a single file name component,\n\ relative to a directory: $TMPDIR, if set; else the\n\ directory specified via -p; else /tmp [deprecated]\n\ @@ -158,6 +156,7 @@ main (int argc, char **argv) char *suffix = NULL; bool use_dest_dir = false; bool deprecated_t_option = false; + bool tmpdir_option = false; bool create_directory = false; bool dry_run = false; int status = EXIT_SUCCESS; @@ -183,6 +182,7 @@ main (int argc, char **argv) case 'p': dest_dir_arg = optarg; use_dest_dir = true; + tmpdir_option = true; break; case 'q': suppress_stderr = true; @@ -195,11 +195,6 @@ main (int argc, char **argv) dry_run = true; break; - case TMPDIR_OPTION: - use_dest_dir = true; - dest_dir_arg = optarg; - break; - case SUFFIX_OPTION: suffix = optarg; break; @@ -223,6 +218,12 @@ main (int argc, char **argv) _("failed to redirect stderr to /dev/null")); } + if (deprecated_t_option && tmpdir_option) + { + error (0, 0, _("the deprecated -t option is not allowed with --tmpdir")); + usage (EXIT_FAILURE); + } + n_args = argc - optind; if (2 <= n_args) { diff --git a/tests/misc/mktemp.pl b/tests/misc/mktemp.pl index b15b669..f9baac3 100755 --- a/tests/misc/mktemp.pl +++ b/tests/misc/mktemp.pl @@ -64,6 +64,11 @@ my @Tests = {ERR=>"$prog: too few X's in template 'foo.XX'\n"}], ['too-few-xq', '-q foo.XX', {EXIT => 1} ], + ['t-and-tmpdir', '-t --tmpdir', + {ERR=>"$prog: the deprecated -t option is not allowed with --tmpdir\n" + . "Try '$prog --help' for more information.\n"}, {EXIT => 1} ], + ['t-and-tmpdir-q', '-q -t --tmpdir', {EXIT => 1} ], + ['1f', 'bar.XXXX', {OUT => "bar.ZZZZ\n"}, {OUT_SUBST => 's,\.....$,.ZZZZ,'}, {POST => sub { my ($f) = @_; defined $f or return; chomp $f; -- 1.7.7.6 --------------010604050106040402000606-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 25 05:32:37 2013 Received: (at 15425) by debbugs.gnu.org; 25 Sep 2013 09:32:37 +0000 Received: from localhost ([127.0.0.1]:34426 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VOlSW-0001cB-Av for submit@debbugs.gnu.org; Wed, 25 Sep 2013 05:32:36 -0400 Received: from mail1.vodafone.ie ([213.233.128.43]:1051) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VOlSU-0001c3-K9 for 15425@debbugs.gnu.org; Wed, 25 Sep 2013 05:32:35 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAKmsQlJtTn0Q/2dsb2JhbAANTsFbgnuBNIMZAQEBBDIBVgsNCwklDwJGBgEMCAEBsEuTLo8eOoQdA5QfijaOQw Received: from unknown (HELO [192.168.1.79]) ([109.78.125.16]) by mail1.vodafone.ie with ESMTP; 25 Sep 2013 10:32:33 +0100 Message-ID: <5242ADB0.60009@draigBrady.com> Date: Wed, 25 Sep 2013 10:32:32 +0100 From: =?windows-1252?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 15425@debbugs.gnu.org, assafgordon@gmail.com, Eric Blake Subject: Re: bug#15425: mktemp - conflicting options affected by ENV References: <523C7CD1.1090907@gmail.com> <523CE4DF.7030106@draigBrady.com> <523CEAFB.3060102@draigBrady.com> <523D07F5.6060708@draigBrady.com> In-Reply-To: <523D07F5.6060708@draigBrady.com> X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15425 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 09/21/2013 03:44 AM, Pádraig Brady wrote: > On 09/21/2013 01:40 AM, Pádraig Brady wrote: >> On 09/21/2013 01:14 AM, Pádraig Brady wrote: >>> On 09/20/2013 05:50 PM, Assaf Gordon wrote: >>>> Hello, >>>> >>>> Not sure if this is a bug or just unintended side-effect, but it caused some scripts here to fail and took a while to troubleshoot: >>>> It basically boils down to the interplay between the deprecated "-t" "-p" and "$TMPDIR" and "--tmpdir". >>>> >>>> === >>>> ## >>>> ## Problem 1: "-t" and TMPDIR (if non-empty) overrides "--tmpdir" >>>> ## >>>> $ TMPDIR= mktemp -u --tmpdir=. -t XXXXXX >>>> ./og9G5s >>>> $ TMPDIR=/foo/ mktemp -u --tmpdir=. -t XXXXXX >>>> /foo/AAWcOl >>> >>> Yes this is confusing, and _not_ order dependent: >>> >>> $ TMPDIR=/foo/ mktemp -t -u --tmpdir=. XXXXXX >>> /foo/AAWcOl >>> >>>> >>>> ## >>>> ## Problem 2: if TMPDIR is empty, "--tmpdir" overrides "-p", despite having "-t" >>>> ## >>>> $ TMPDIR=/foo/ mktemp -u -p /bar/ --tmpdir=. -t XXXXXX >>>> /foo/tHXcrq >>>> $ TMPDIR= mktemp -u -p /bar/ --tmpdir=. -t XXXXXX >>>> ./OfWXSS >>>> ## I'd expect the above to use "/bar/OfWXSS", to be consistent with TMPDIR overriding "--tmpdir". >>>> === >>> >>> Also confusing, and order dependent too: >>> >>> $ mktemp -p /aaa -u --tmpdir=. asdf/XXXX >>> ./asdf/wdIT >>> $ mktemp -u --tmpdir=. -p /aaa asdf/XXXX >>> /aaa/asdf/3Jc7 >>> >>>> I realize "-t" and "-p" are deprecated, and it's best not to meddle with them - >>>> but for consistency, perhaps consider having the new "--tmpdir" always take precedence over "-t" and "-p" ? >>>> or print a warning to STDERR when "-t" and "--tmpdir" are mixed? >>> >>> Yes I agree that --tmpdir should override -pt no matter what the order. >>> In fact there is no reason to use -pt with --tmpdir and since the former >>> are deprecated, I suggest we just disallow that combination with an error. >>> >>> Patch coming up. >> >> I also see the --help says that -p implies -t >> AFAICS -t in the context of -p just means to interpret template as a single file without dirs, >> however the example below shows that -t is not in fact implied with -p >> >> $ mktemp -u -p dir1 dir2/XXXXXX >> dir1/dir2/qQBdsf >> $ mktemp -u -t -p dir1 dir2/XXXXXX >> src/mktemp: invalid template, ‘dir2/XXXXXX’, contains directory separator >> >> So rather than adjusting any functionality of these deprecated options, >> I'll just remove the --help text saying that -t is implied. > > Which would make -p = --tmpdir, which is what the code has done > since being introduced to coreutils 6 years ago, and what the > texinfo has documented for the last 4 years. So I've just aligned > the --help to say -p is the short form of --tmpdir. > > Hopefully the attached addresses all these issues. I'll push this soon, unless there are objections to the above "undeprecation" of -p. thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 26 00:36:50 2013 Received: (at 15425) by debbugs.gnu.org; 26 Sep 2013 04:36:50 +0000 Received: from localhost ([127.0.0.1]:36716 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VP3Jq-0006js-7h for submit@debbugs.gnu.org; Thu, 26 Sep 2013 00:36:50 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:58485) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VP3Jo-0006jk-EV for 15425@debbugs.gnu.org; Thu, 26 Sep 2013 00:36:48 -0400 Received: by mail-pb0-f45.google.com with SMTP id mc17so594949pbc.18 for <15425@debbugs.gnu.org>; Wed, 25 Sep 2013 21:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=EaF0+LcilKKeQO6aUkkTStP65JfDZ0Emh2fN6/n7xk0=; b=RgA/SVWx/gc1T1b2BacFLbd62s4J0uU2tjJWvRInx8m3+hfUWGhd0A1FUWZ8S/qhfi SxSpOHkIHPa27FAWmMwQgF/n/4HK4IB80STQ5t1L1AVFVRJprLleB5pYxqzaVhAfS9/f iJdRqFTTTVs4spdUYuekCxXdPLa8T/pke650EpRV9oVNJDksy0OBCl66vNVTI2veJf++ aoroOfIPyvF55osFXzI+qnPCj9HGesKaFh4SY1FaMek/KD1b4Qlh2EudM3aOnBNRrhJQ zTQjzafHB2rgtrIYHs9h07v/aoXI8Trr50GqGdM/SlNr3Wa2QBec3QnUa0SXMI+Mxe9H puCg== X-Received: by 10.66.150.41 with SMTP id uf9mr3041742pab.108.1380170207551; Wed, 25 Sep 2013 21:36:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.6.66 with HTTP; Wed, 25 Sep 2013 21:36:27 -0700 (PDT) In-Reply-To: <5242ADB0.60009@draigBrady.com> References: <523C7CD1.1090907@gmail.com> <523CE4DF.7030106@draigBrady.com> <523CEAFB.3060102@draigBrady.com> <523D07F5.6060708@draigBrady.com> <5242ADB0.60009@draigBrady.com> From: Jim Meyering Date: Wed, 25 Sep 2013 21:36:27 -0700 X-Google-Sender-Auth: 3MqbQfpn9EgquKRXj5mC0suFlp8 Message-ID: Subject: Re: bug#15425: mktemp - conflicting options affected by ENV To: =?ISO-8859-1?Q?P=E1draig_Brady?= Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 15425 Cc: 15425@debbugs.gnu.org, assafgordon@gmail.com, Eric Blake X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) > I'll push this soon, unless there are objections > to the above "undeprecation" of -p. Go for it. That seems best. Thank you. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 26 09:00:08 2013 Received: (at 15425) by debbugs.gnu.org; 26 Sep 2013 13:00:08 +0000 Received: from localhost ([127.0.0.1]:37503 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VPBAr-0006RG-RZ for submit@debbugs.gnu.org; Thu, 26 Sep 2013 09:00:07 -0400 Received: from mail1.vodafone.ie ([213.233.128.43]:50700) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VPBAl-0006QD-L7 for 15425@debbugs.gnu.org; Thu, 26 Sep 2013 09:00:00 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq0BAG0vRFJtTjSj/2dsb2JhbAANToM/TIkMt02BOYMZAQEBBEcyEAsNBAMBAgEJFg8JAwIBAgE9CAYNAQUCAQGICalohQOOOI9AEQeEHgOQJ4kFhSqFbohW Received: from unknown (HELO [192.168.1.79]) ([109.78.52.163]) by mail1.vodafone.ie with ESMTP; 26 Sep 2013 13:59:57 +0100 Message-ID: <52442FCA.4060005@draigBrady.com> Date: Thu, 26 Sep 2013 13:59:54 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#15425: mktemp - conflicting options affected by ENV References: <523C7CD1.1090907@gmail.com> <523CE4DF.7030106@draigBrady.com> <523CEAFB.3060102@draigBrady.com> <523D07F5.6060708@draigBrady.com> <5242ADB0.60009@draigBrady.com> In-Reply-To: X-Enigmail-Version: 1.5.2 Content-Type: multipart/mixed; boundary="------------070802020708040009050209" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15425 Cc: 15425@debbugs.gnu.org, assafgordon@gmail.com, Eric Blake X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------070802020708040009050209 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit On 09/26/2013 05:36 AM, Jim Meyering wrote: >> I'll push this soon, unless there are objections >> to the above "undeprecation" of -p. > > Go for it. That seems best. Thank you. That -p = --tmpdir aspect is OK. But on consideration, erroring on -p,-t is too harsh. Really -t is just a mode to operate in, i.e. enforce no '/' in template, and give precedence to TMPDIR over --tmpdir Hopefully the attached documentation only patch suffices to clear things up. BTW I noticed this variation which could be used to generate passwords or something: $ mktemp -u -t -p '' XXXXXXXX L5awccB1 However without -t, '/tmp/' is inserted. I'm inclined to change to not output '/tmp/' here? $ mktemp -u -p '' XXXXXXXX /tmp/L5awccB1 thanks, Pádraig. --------------070802020708040009050209 Content-Type: text/x-patch; name="mktemp-pt.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mktemp-pt.patch" >From bc10a871cd36a3089e28c4fdde6822ee5ecbda96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sat, 21 Sep 2013 03:33:12 +0100 Subject: [PATCH] doc: clarify the mktemp option descriptions * doc/coreutils.texi (mktemp invocation): Clarify that _all_ error messages are suppressed with the -q option. * src/mktemp.c (usage): Synchronize the -p option description with the logic and info docs. I.E. that -p is just an alias of --tmpdir. Fixes http://bugs.gnu.org/154245 --- doc/coreutils.texi | 5 +++-- src/mktemp.c | 15 +++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 5b2f624..17cdbc3 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -13421,8 +13421,9 @@ umask is more restrictive. @itemx --quiet @opindex -q @opindex --quiet -Suppress diagnostics about failure to create a file or directory. The -exit status will still reflect whether a file was created. +Suppress all error messages, including command option syntax errors, +and failure to create a file or directory. +The exit status will still reflect whether a file was created. @item -u @itemx --dry-run diff --git a/src/mktemp.c b/src/mktemp.c index 44845c3..e169605 100644 --- a/src/mktemp.c +++ b/src/mktemp.c @@ -43,7 +43,6 @@ static const char *default_template = "tmp.XXXXXXXXXX"; enum { SUFFIX_OPTION = CHAR_MAX + 1, - TMPDIR_OPTION }; static struct option const longopts[] = @@ -52,7 +51,7 @@ static struct option const longopts[] = {"quiet", no_argument, NULL, 'q'}, {"dry-run", no_argument, NULL, 'u'}, {"suffix", required_argument, NULL, SUFFIX_OPTION}, - {"tmpdir", optional_argument, NULL, TMPDIR_OPTION}, + {"tmpdir", optional_argument, NULL, 'p'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} @@ -78,27 +77,24 @@ Files are created u+rw, and directories u+rwx, minus umask restrictions.\n\ fputs (_("\ -d, --directory create a directory, not a file\n\ -u, --dry-run do not create anything; merely print a name (unsafe)\n\ - -q, --quiet suppress diagnostics about file/dir-creation failure\n\ + -q, --quiet suppress all error messages\n\ "), stdout); fputs (_("\ --suffix=SUFF append SUFF to TEMPLATE; SUFF must not contain a slash.\n\ This option is implied if TEMPLATE does not end in X\n\ "), stdout); fputs (_("\ - --tmpdir[=DIR] interpret TEMPLATE relative to DIR; if DIR is not\n\ + -p DIR, --tmpdir[=DIR] interpret TEMPLATE relative to DIR; if DIR is not\n\ specified, use $TMPDIR if set, else /tmp. With\n\ this option, TEMPLATE must not be an absolute name;\n\ unlike with -t, TEMPLATE may contain slashes, but\n\ mktemp creates only the final component\n\ "), stdout); - fputs ("\n", stdout); fputs (_("\ - -p DIR use DIR as a prefix; implies -t [deprecated]\n\ -t interpret TEMPLATE as a single file name component,\n\ relative to a directory: $TMPDIR, if set; else the\n\ directory specified via -p; else /tmp [deprecated]\n\ "), stdout); - fputs ("\n", stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_ancillary_info (); @@ -195,11 +191,6 @@ main (int argc, char **argv) dry_run = true; break; - case TMPDIR_OPTION: - use_dest_dir = true; - dest_dir_arg = optarg; - break; - case SUFFIX_OPTION: suffix = optarg; break; -- 1.7.7.6 --------------070802020708040009050209-- From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 06 13:10:27 2013 Received: (at 15425) by debbugs.gnu.org; 6 Oct 2013 17:10:27 +0000 Received: from localhost ([127.0.0.1]:57894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSrqc-00025y-As for submit@debbugs.gnu.org; Sun, 06 Oct 2013 13:10:27 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:20652) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSrqZ-00025m-Dn for 15425@debbugs.gnu.org; Sun, 06 Oct 2013 13:10:24 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArcBAA6ZUVJtTA6D/2dsb2JhbAANTIM/TIkLuBOBKYMZAQEBBIEJCw0EAwECAQkWDwkDAgECAT0IEwYCAQGICad3kmqPQAwMhCMDkCiJCIUuhXCIWA Received: from unknown (HELO [192.168.1.79]) ([109.76.14.131]) by mail2.vodafone.ie with ESMTP; 06 Oct 2013 18:10:12 +0100 Message-ID: <5251996E.6020601@draigBrady.com> Date: Sun, 06 Oct 2013 18:10:06 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 15425@debbugs.gnu.org Subject: Re: bug#15425: mktemp - conflicting options affected by ENV References: <523C7CD1.1090907@gmail.com> <523CE4DF.7030106@draigBrady.com> <523CEAFB.3060102@draigBrady.com> <523D07F5.6060708@draigBrady.com> <5242ADB0.60009@draigBrady.com> <52442FCA.4060005@draigBrady.com> In-Reply-To: <52442FCA.4060005@draigBrady.com> X-Enigmail-Version: 1.5.2 Content-Type: multipart/mixed; boundary="------------070509080104070705000804" X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 09/26/2013 01:59 PM, Pádraig Brady wrote: > On 09/26/2013 05:36 AM, Jim Meyering wrote: >>> I'll push this soon, unless there are objections >>> to the above "undeprecation" of -p. >> >> Go for it. That seems best. Thank you. > > That -p = --tmpdir aspect is OK. > > But on consideration, erroring on -p,-t is too harsh. > Really -t is just a mode to operate in, > i.e. enforce no '/' in template, and give precedence > to TMPDIR over --tmpdir > Hopefully the attached documentation only patch > suffices to clear things up. > > BTW I noticed this variation which could be > used to generate passwords or something: > > $ mktemp -u -t -p '' XXXXXXXX > L5awccB1 > > However without -t, '/tmp/' is inserted. > I'm inclined to change to not output '/tmp/' here? > > $ mktemp -u -p '' XXXXXXXX > /tmp/L5awccB1 [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.233.128.44 listed in list.dnswl.org] X-Debbugs-Envelope-To: 15425 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 09/26/2013 01:59 PM, Pádraig Brady wrote: > On 09/26/2013 05:36 AM, Jim Meyering wrote: >>> I'll push this soon, unless there are objections >>> to the above "undeprecation" of -p. >> >> Go for it. That seems best. Thank you. > > That -p = --tmpdir aspect is OK. > > But on consideration, erroring on -p,-t is too harsh. > Really -t is just a mode to operate in, > i.e. enforce no '/' in template, and give precedence > to TMPDIR over --tmpdir > Hopefully the attached documentation only patch > suffices to clear things up. > > BTW I noticed this variation which could be > used to generate passwords or something: > > $ mktemp -u -t -p '' XXXXXXXX > L5awccB1 > > However without -t, '/tmp/' is inserted. > I'm inclined to change to not output '/tmp/' here? > > $ mktemp -u -p '' XXXXXXXX > /tmp/L5awccB1 [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.233.128.44 listed in list.dnswl.org] 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] This is a multi-part message in MIME format. --------------070509080104070705000804 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit On 09/26/2013 01:59 PM, Pádraig Brady wrote: > On 09/26/2013 05:36 AM, Jim Meyering wrote: >>> I'll push this soon, unless there are objections >>> to the above "undeprecation" of -p. >> >> Go for it. That seems best. Thank you. > > That -p = --tmpdir aspect is OK. > > But on consideration, erroring on -p,-t is too harsh. > Really -t is just a mode to operate in, > i.e. enforce no '/' in template, and give precedence > to TMPDIR over --tmpdir > Hopefully the attached documentation only patch > suffices to clear things up. > > BTW I noticed this variation which could be > used to generate passwords or something: > > $ mktemp -u -t -p '' XXXXXXXX > L5awccB1 > > However without -t, '/tmp/' is inserted. > I'm inclined to change to not output '/tmp/' here? > > $ mktemp -u -p '' XXXXXXXX > /tmp/L5awccB1 Actually the best way to generate random chars like the above is to avoid -p entirely. So I've made -t consistent and output /tmp/... in the above case. Also I matched the -q option up with the documentation. The documented functionality made sense, which was to suppress only I/O errors, but the existing code suppressed almost all errors, including most usage errors. So I fixed that up in a second patch. Both updated patches are attached, and already pushed. thanks, Pádraig. --------------070509080104070705000804 Content-Type: text/x-patch; name="mktemp-match-docs.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mktemp-match-docs.patch" >From 8e67c2dec1a595619d540bc3e52c2dfcf61a63a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sat, 21 Sep 2013 03:33:12 +0100 Subject: [PATCH 1/2] mktemp: synchronize the -p option with docs * src/mktemp.c (usage): Synchronize the -p option description with the logic and info docs. I.E. that -p is just an alias of --tmpdir. Also for consistency treat --tmpdir='' the same with or without -t. I.E. always ignore the --tmpdir option if the param is empty. Fixes http://bugs.gnu.org/15425 --- src/mktemp.c | 22 ++++++++-------------- 1 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/mktemp.c b/src/mktemp.c index 44845c3..41d5763 100644 --- a/src/mktemp.c +++ b/src/mktemp.c @@ -43,7 +43,6 @@ static const char *default_template = "tmp.XXXXXXXXXX"; enum { SUFFIX_OPTION = CHAR_MAX + 1, - TMPDIR_OPTION }; static struct option const longopts[] = @@ -52,7 +51,7 @@ static struct option const longopts[] = {"quiet", no_argument, NULL, 'q'}, {"dry-run", no_argument, NULL, 'u'}, {"suffix", required_argument, NULL, SUFFIX_OPTION}, - {"tmpdir", optional_argument, NULL, TMPDIR_OPTION}, + {"tmpdir", optional_argument, NULL, 'p'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} @@ -85,20 +84,17 @@ Files are created u+rw, and directories u+rwx, minus umask restrictions.\n\ This option is implied if TEMPLATE does not end in X\n\ "), stdout); fputs (_("\ - --tmpdir[=DIR] interpret TEMPLATE relative to DIR; if DIR is not\n\ + -p DIR, --tmpdir[=DIR] interpret TEMPLATE relative to DIR; if DIR is not\n\ specified, use $TMPDIR if set, else /tmp. With\n\ this option, TEMPLATE must not be an absolute name;\n\ unlike with -t, TEMPLATE may contain slashes, but\n\ mktemp creates only the final component\n\ "), stdout); - fputs ("\n", stdout); fputs (_("\ - -p DIR use DIR as a prefix; implies -t [deprecated]\n\ -t interpret TEMPLATE as a single file name component,\n\ relative to a directory: $TMPDIR, if set; else the\n\ directory specified via -p; else /tmp [deprecated]\n\ "), stdout); - fputs ("\n", stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_ancillary_info (); @@ -195,11 +191,6 @@ main (int argc, char **argv) dry_run = true; break; - case TMPDIR_OPTION: - use_dest_dir = true; - dest_dir_arg = optarg; - break; - case SUFFIX_OPTION: suffix = optarg; break; @@ -283,9 +274,12 @@ main (int argc, char **argv) if (deprecated_t_option) { char *env = getenv ("TMPDIR"); - dest_dir = (env && *env - ? env - : (dest_dir_arg ? dest_dir_arg : "/tmp")); + if (env && *env) + dest_dir = env; + else if (dest_dir_arg && *dest_dir_arg) + dest_dir = dest_dir_arg; + else + dest_dir = "/tmp"; if (last_component (template) != template) error (EXIT_FAILURE, 0, -- 1.7.7.6 >From 0c1d7917f19b4865544ab9f1b13dfcdfd4e65275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sun, 6 Oct 2013 17:26:51 +0100 Subject: [PATCH 2/2] mktemp: with --quiet, only suppress I/O errors The reason for having a --quiet option is to suppress only some subset of possible errors. The most useful separation here is with usage/internal errors, and errors due to file creation etc. (i.e. I/O errors). * src/mktemp.c (main): Match the --help and info docs and only suppress the file/dir creation error messages. * tests/misc/mktemp.pl: Adjust accordingly. --- src/mktemp.c | 27 ++++++++++----------------- tests/misc/mktemp.pl | 8 ++------ 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/mktemp.c b/src/mktemp.c index 41d5763..05530a3 100644 --- a/src/mktemp.c +++ b/src/mktemp.c @@ -26,7 +26,6 @@ #include "error.h" #include "filenamecat.h" #include "quote.h" -#include "stdio--.h" #include "tempname.h" /* The official name of this program (e.g., no 'g' prefix). */ @@ -147,7 +146,7 @@ main (int argc, char **argv) { char const *dest_dir; char const *dest_dir_arg = NULL; - bool suppress_stderr = false; + bool suppress_file_err = false; int c; unsigned int n_args; char *template; @@ -181,7 +180,7 @@ main (int argc, char **argv) use_dest_dir = true; break; case 'q': - suppress_stderr = true; + suppress_file_err = true; break; case 't': use_dest_dir = true; @@ -205,15 +204,6 @@ main (int argc, char **argv) } } - if (suppress_stderr) - { - /* From here on, redirect stderr to /dev/null. - A diagnostic from getopt_long, above, would still go to stderr. */ - if (!freopen ("/dev/null", "wb", stderr)) - error (EXIT_FAILURE, errno, - _("failed to redirect stderr to /dev/null")); - } - n_args = argc - optind; if (2 <= n_args) { @@ -317,8 +307,9 @@ main (int argc, char **argv) int err = mkdtemp_len (dest_name, suffix_len, x_count, dry_run); if (err != 0) { - error (0, errno, _("failed to create directory via template %s"), - quote (template)); + if (!suppress_file_err) + error (0, errno, _("failed to create directory via template %s"), + quote (template)); status = EXIT_FAILURE; } } @@ -327,8 +318,9 @@ main (int argc, char **argv) int fd = mkstemp_len (dest_name, suffix_len, x_count, dry_run); if (fd < 0 || (!dry_run && close (fd) != 0)) { - error (0, errno, _("failed to create file via template %s"), - quote (template)); + if (!suppress_file_err) + error (0, errno, _("failed to create file via template %s"), + quote (template)); status = EXIT_FAILURE; } } @@ -342,7 +334,8 @@ main (int argc, char **argv) { int saved_errno = errno; remove (dest_name); - error (EXIT_FAILURE, saved_errno, _("write error")); + if (!suppress_file_err) + error (EXIT_FAILURE, saved_errno, _("write error")); } } diff --git a/tests/misc/mktemp.pl b/tests/misc/mktemp.pl index b15b669..d47371c 100755 --- a/tests/misc/mktemp.pl +++ b/tests/misc/mktemp.pl @@ -55,14 +55,12 @@ my @Tests = ( # test-name, [option, option, ...] {OUT=>"expected-output"} # - ['too-many', 'a b', + ['too-many', '-q a b', {ERR=>"$prog: too many templates\n" . "Try '$prog --help' for more information.\n"}, {EXIT => 1} ], - ['too-many-q', '-q a b', {EXIT => 1} ], - ['too-few-x', 'foo.XX', {EXIT => 1}, + ['too-few-x', '-q foo.XX', {EXIT => 1}, {ERR=>"$prog: too few X's in template 'foo.XX'\n"}], - ['too-few-xq', '-q foo.XX', {EXIT => 1} ], ['1f', 'bar.XXXX', {OUT => "bar.ZZZZ\n"}, {OUT_SUBST => 's,\.....$,.ZZZZ,'}, @@ -148,11 +146,9 @@ my @Tests = ['suffix6f', 'aXXXX/b', {EXIT=>1}, {ERR=>"$prog: invalid suffix '/b', contains directory separator\n"}], - ['suffix6f-q', '-q aXXXX/b', {EXIT=>1}], ['suffix7f', '--suffix= aXXXXb', {EXIT=>1}, {ERR=>"$prog: with --suffix, template 'aXXXXb' must end in X\n"}], - ['suffix7f-q', '-q --suffix= aXXXXb', {EXIT=>1}], ['suffix7d', '-d --suffix=aXXXXb ""', {EXIT=>1}, {ERR=>"$prog: with --suffix, template '' must end in X\n"}], -- 1.7.7.6 --------------070509080104070705000804-- From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 07 07:22:37 2013 Received: (at 15425) by debbugs.gnu.org; 7 Oct 2013 11:22:37 +0000 Received: from localhost ([127.0.0.1]:59543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VT8tY-0004ck-50 for submit@debbugs.gnu.org; Mon, 07 Oct 2013 07:22:36 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:8647) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VT8tV-0004ca-02 for 15425@debbugs.gnu.org; Mon, 07 Oct 2013 07:22:34 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApYBAEiYUlJtTLsC/2dsb2JhbAANTIM/sF6RD4EygxkBAQEEMgFWCw0HBAklDwJGEwYCAQGIDqdUkwaPWBaEDQOZMIUujkg Received: from unknown (HELO [192.168.1.79]) ([109.76.187.2]) by mail2.vodafone.ie with ESMTP; 07 Oct 2013 12:22:31 +0100 Message-ID: <52529976.304@draigBrady.com> Date: Mon, 07 Oct 2013 12:22:30 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 15425@debbugs.gnu.org Subject: Re: bug#15425: mktemp - conflicting options affected by ENV References: <523C7CD1.1090907@gmail.com> <523CE4DF.7030106@draigBrady.com> <523CEAFB.3060102@draigBrady.com> <523D07F5.6060708@draigBrady.com> <5242ADB0.60009@draigBrady.com> <52442FCA.4060005@draigBrady.com> <5251996E.6020601@draigBrady.com> In-Reply-To: <5251996E.6020601@draigBrady.com> X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 10/06/2013 06:10 PM, Pádraig Brady wrote: > Also I matched the -q option up with the documentation. > The documented functionality made sense, which was to > suppress only I/O errors, but the existing code suppressed > almost all errors, including most usage errors. > So I fixed that up in a second patch. [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.233.128.44 listed in list.dnswl.org] X-Debbugs-Envelope-To: 15425 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 10/06/2013 06:10 PM, Pádraig Brady wrote: > Also I matched the -q option up with the documentation. > The documented functionality made sense, which was to > suppress only I/O errors, but the existing code suppressed > almost all errors, including most usage errors. > So I fixed that up in a second patch. [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.233.128.44 listed in list.dnswl.org] 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] On 10/06/2013 06:10 PM, Pádraig Brady wrote: > Also I matched the -q option up with the documentation. > The documented functionality made sense, which was to > suppress only I/O errors, but the existing code suppressed > almost all errors, including most usage errors. > So I fixed that up in a second patch. I was caught out by inconsistent exit() handling in this area, which required this follow up commit. commit cba81e7b84f27385e254cddd065bb16c98a5d045 Author: Pádraig Brady Date: Mon Oct 7 11:59:53 2013 +0100 mktemp: fix incorrect exit status from previous commit * src/mktemp.c (main): Use an exit() strategy consistent with the previous clauses dealing with optional error messages to ensure we exit with the correct status in all cases. Prompted by the continuous integration build failure at: http://hydra.nixos.org/build/6412979 diff --git a/src/mktemp.c b/src/mktemp.c index 05530a3..074676f 100644 --- a/src/mktemp.c +++ b/src/mktemp.c @@ -335,7 +335,8 @@ main (int argc, char **argv) int saved_errno = errno; remove (dest_name); if (!suppress_file_err) - error (EXIT_FAILURE, saved_errno, _("write error")); + error (0, saved_errno, _("write error")); + status = EXIT_FAILURE; } } From unknown Mon Jun 16 23:36:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 04 Nov 2013 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator