Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: sysopen (was Re: '>>' does not create file if set -C (noclobber) is active)



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;



Messages sorted by: Reverse Date, Date, Thread, Author