From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8591 invoked by alias); 28 Jun 2015 18:38:23 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35656 Received: (qmail 17583 invoked from network); 28 Jun 2015 18:38:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=FneTsU2Nps/Zf8oRiCm5M2xSXI4g9qIfDCSzub7Lo/U=; b=HHkAloLeeeINGDd3OpoUhJjY4lg63wjdNlmprM/wJP+h34O8isyY9CCf8gWwllRdrr oIR5MS71rUcK/pCpJGtQsQk6JlQ58bzHsAuATAsIM7vUr0GXY/y5Ouid9plBIV8dwSLk 8sT3CW0A+OKmZN4rNnV/DvEOtmS+3hb80N5ft/qmNTSblMKKKGkeRtn9pNOnaVwP1E2u F6hO/C+Y90q9OQ9IHx1BfsTOft0cNohGp/zepXxr/QmS0p0EuBIhT/1dFn1PL7OIFVTJ m61tMhb6S7DESWZc8X8KuYufo5RE4Cfo0Sm9FSBtijlNRhu/PvPG9qzP9GMxI6aBu2Z5 6SEQ== X-Gm-Message-State: ALoCoQnR6wn3TLxkxB0TkYZQ2lM1CY0qzYVOdPHP0EswvfG1SACa0jjfJQqnwSMgJFTMAXSme2Dy X-Received: by 10.60.101.137 with SMTP id fg9mr10313390oeb.83.1435516699105; Sun, 28 Jun 2015 11:38:19 -0700 (PDT) From: Bart Schaefer Message-Id: <150628113814.ZM1638@torch.brasslantern.com> Date: Sun, 28 Jun 2015 11:38:14 -0700 In-Reply-To: <20150628140050.GA10570@chaz.gmail.com> Comments: In reply to Stephane Chazelas "Re: '>>' does not create file if set -C (noclobber) is active" (Jun 28, 3:00pm) References: <558B5342.2090706@inlv.org> <150624184916.ZM19079@torch.brasslantern.com> <558B65EB.3060204@inlv.org> <150625003047.ZM19218@torch.brasslantern.com> <558D5E34.3020505@inlv.org> <20150627180230.5fda7e09@ntlworld.com> <558F397D.9030708@inlv.org> <20150628074837.GB4818@chaz.gmail.com> <16434.1435482953@thecus.kiddle.eu> <20150628140050.GA10570@chaz.gmail.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: '>>' does not create file if set -C (noclobber) is active MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jun 28, 3:00pm, Stephane Chazelas wrote: } } That's very similar with redirection operators. Some shells like } ksh93 have a plethora of different operators. We could for } instance add a >@ for O_NOFOLLOW, >* for O_CLOEXEC... etc, but } it becomes unclear how they can be combined, while <(flags)> } would make it neater. "<>" already means open r/w, and "" is syntactically ambiguous with redirecting input from the file named flags followed by redirecting output. ">*" is multio syntax, and if you add ksh globbing, ">@" is ambiguous. Let me remind everyone that redirection operators were designed as a front-end on stdio, e.g. fopen(3) and friends, and not on open(2) and similar OS-level calls. fopen(3) doesn't interface to the full suite of flags supported by open(2). Throw in all this additional detail and you are effectively preventing the shell implementation from using the stdio library, which could limit portability. Therefore the sysopen suggestion is probably the most appropriate one. The next-best idea I can think of offhand would be to have a variable that behaves like the umask does for file permissions, except that it applies to the file opening mode instead. You could tweak this in the list of variables that prefix the command, e.g., OPENMODE=04600 cat < $file There could be a builtin command to translate symbolic names into the bits for OPENMODE e.g. OPENMODE=$(openmode O_EXCL O_NOCTTY O_NONBLOCK) cat < $file Or I suppose this could all be done as a pre-command modifier: openmode O_EXCL,O_NOCTTY,O_NONBLOCK cat < $file All of this would simply be ignored in environments where it could not be supported, which is why I think an explicit sysopen that could fail with well-defined error conditions is preferable.