zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@zsh.org
Subject: Re: PATCH: sysopen (was Re: '>>' does not create file if set -C (noclobber) is active)
Date: Fri, 31 Jul 2015 14:41:33 +0200	[thread overview]
Message-ID: <31988.1438346493@thecus.kiddle.eu> (raw)
In-Reply-To: <20150724115733.44531b77@pwslap01u.europe.root.pri>

On 24 Jul, Peter wrote:
> One very minor comment now I've tried this:
> 
> % sysread -i fd
> sysread: integer expected: fd
> 
> I think it would probably be appropriate and consistent with other
> similar contexts for this to do matn eval, even though the workaround is
> obvious and trivial.  C.f. "sysopen -u fd" (though of course there's no
> choice in that case) and
> 
> % print $(( systell(fd) ))
> 8192
> 
> However, we're not actually missing anything by not.

I don't have a strong opinion either way on this.
This could apply to print and read just as much as sysread, syswrite and
sysseek.

By the way, I'm happy with both documentation patches.

Mikael wrote:
> Was there a reason the new commands were not made subcommands to
> zsystem?

sysread and syswrite are not zsystem subcommands.

What is the purpose of zsystem (as opposed to a direct sysflock)? Is it
that flock is not supported by some common systems?

Coverity noticed that I'd made one part more complicated than it needs
to be so this cleans that up (the !append was tautologous).

Oliver

diff --git a/Src/Modules/system.c b/Src/Modules/system.c
index a1ed33a..1ab1fb1 100644
--- a/Src/Modules/system.c
+++ b/Src/Modules/system.c
@@ -311,8 +311,7 @@ bin_sysopen(char *nam, char **args, Options ops, UNUSED(int func))
     int write = OPT_ISSET(ops, 'w');
     int append = OPT_ISSET(ops, 'a') ? O_APPEND : 0;
     int flags = O_NOCTTY | append | ((append || write) ?
-	(read ? O_RDWR : O_WRONLY) :
-	(!append || read) ? O_RDONLY : O_WRONLY);
+	(read ? O_RDWR : O_WRONLY) : O_RDONLY);
     char *opt, *ptr, *nextopt, *fdvar;
     int o, fd, explicit = -1;
     mode_t perms = 0666;


  parent reply	other threads:[~2015-07-31 12:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25  1:02 '>>' does not create file if set -C (noclobber) is active Martijn Dekker
2015-06-25  1:49 ` Bart Schaefer
2015-06-25  2:22   ` Martijn Dekker
2015-06-25  7:30     ` Bart Schaefer
2015-06-25 14:04       ` Stephane Chazelas
2015-06-25 16:00         ` Bart Schaefer
2015-06-25 19:20           ` Chet Ramey
2015-06-26 14:14       ` Martijn Dekker
2015-06-26 20:15         ` Bart Schaefer
2015-06-27  1:54           ` Martijn Dekker
2015-06-27  3:38             ` Bart Schaefer
2015-06-27 17:02         ` Peter Stephenson
2015-06-28  0:02           ` Martijn Dekker
2015-06-28  0:46             ` Martijn Dekker
2015-06-28  7:48             ` Stephane Chazelas
2015-06-28  9:15               ` Oliver Kiddle
2015-06-28 14:00                 ` Stephane Chazelas
2015-06-28 18:38                   ` Bart Schaefer
2015-06-28 19:30                     ` Stephane Chazelas
2015-07-23  2:56                     ` PATCH: sysopen (was Re: '>>' does not create file if set -C (noclobber) is active) Oliver Kiddle
2015-07-24 10:57                       ` Peter Stephenson
2015-07-24 11:55                         ` Peter Stephenson
2015-07-30 11:05                           ` Mikael Magnusson
2015-07-31 12:41                         ` Oliver Kiddle [this message]
2015-07-31 14:02                           ` Mikael Magnusson
2015-06-28 17:19             ` '>>' does not create file if set -C (noclobber) is active Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31988.1438346493@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).