9front - general discussion about 9front
 help / color / mirror / Atom feed
* [PATCH] syscall(1): remove '\n' from -o output
@ 2020-09-13 13:15 kvik
  2020-09-13 15:32 ` [9front] " ori
  0 siblings, 1 reply; 4+ messages in thread
From: kvik @ 2020-09-13 13:15 UTC (permalink / raw)
  To: 9front

When given the -o flag syscall(1) prints the buffer with an appended
newline, making interactive usage misleading and scripting quite
awkward.

I propose removing the newline.

The only program using syscall(1) in the base system is wloc(1), which
works fine after the patch.  However, it's likely that people have
worked around this in their own scripts so the patch may break them.

diff -r cd0da90ae546 sys/src/cmd/syscall/syscall.c
--- a/sys/src/cmd/syscall/syscall.c	Sat Sep 12 17:40:41 2020 -0700
+++ b/sys/src/cmd/syscall/syscall.c	Sun Sep 13 14:55:34 2020 +0200
@@ -131,7 +131,7 @@
 				fprint(2, "syscall: return %lld, no error\n", r);
 			}
 			if(oflag)
-				print("%s\n", buf);
+				print("%s", buf);
 			if(xflag){
 				for(j=0; j<r; j++){
 					if(j%16 == 0)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9front] [PATCH] syscall(1): remove '\n' from -o output
  2020-09-13 13:15 [PATCH] syscall(1): remove '\n' from -o output kvik
@ 2020-09-13 15:32 ` ori
  2020-09-17  8:33   ` cinap_lenrek
  0 siblings, 1 reply; 4+ messages in thread
From: ori @ 2020-09-13 15:32 UTC (permalink / raw)
  To: kvik, 9front

> When given the -o flag syscall(1) prints the buffer with an appended
> newline, making interactive usage misleading and scripting quite
> awkward.
> 
> I propose removing the newline.
> 
> The only program using syscall(1) in the base system is wloc(1), which
> works fine after the patch.  However, it's likely that people have
> worked around this in their own scripts so the patch may break them.
> 
> diff -r cd0da90ae546 sys/src/cmd/syscall/syscall.c
> --- a/sys/src/cmd/syscall/syscall.c	Sat Sep 12 17:40:41 2020 -0700
> +++ b/sys/src/cmd/syscall/syscall.c	Sun Sep 13 14:55:34 2020 +0200
> @@ -131,7 +131,7 @@
>  				fprint(2, "syscall: return %lld, no error\n", r);
>  			}
>  			if(oflag)
> -				print("%s\n", buf);
> +				print("%s", buf);
>  			if(xflag){
>  				for(j=0; j<r; j++){
>  					if(j%16 == 0)

Ok by me.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9front] [PATCH] syscall(1): remove '\n' from -o output
  2020-09-13 15:32 ` [9front] " ori
@ 2020-09-17  8:33   ` cinap_lenrek
  2020-09-17 13:32     ` kvik
  0 siblings, 1 reply; 4+ messages in thread
From: cinap_lenrek @ 2020-09-17  8:33 UTC (permalink / raw)
  To: 9front

the print() will also mangle the data (expecting utf-8). maybe it
should just write the buffer to stdout as is?

--
cinap


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9front] [PATCH] syscall(1): remove '\n' from -o output
  2020-09-17  8:33   ` cinap_lenrek
@ 2020-09-17 13:32     ` kvik
  0 siblings, 0 replies; 4+ messages in thread
From: kvik @ 2020-09-17 13:32 UTC (permalink / raw)
  To: 9front

> maybe it should just write the buffer to stdout as is?

Not sure that the current behaviour is particularly useful,
so this would be great.

Going to do it a bit later.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-17 13:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-13 13:15 [PATCH] syscall(1): remove '\n' from -o output kvik
2020-09-13 15:32 ` [9front] " ori
2020-09-17  8:33   ` cinap_lenrek
2020-09-17 13:32     ` kvik

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).