Re: print -R compatibility

2017-02-27 Thread Thorsten Glaser
Hi Jean,

>Sorry for the late reply, I have been away from home due to unexpected
>family issues.

no problem.

>for -e must be fairly limited. As I understand it, the only purpose of
>the option is to cancel a previous -r, which is kind of a corner case.

The ksh93 manpage documents it as such, yes.

>Fair enough. I hope this minor incompatibility won't be a problem for
>out customer.

OK. Handling _that_ would be maximally tricky (escape from the getopts
framework, etc).

>> This will be in the next mksh release.
>
>Thank you very much. I have backported your work to mksh R50 as this is
>what our product includes, and will send to our customer shortly for
>testing.

OK, wonderful, thanks!

>Now that the print command supports option -e and it is documented,
>it should also appear in the command synopsis.

Good catch! I merged it, and while there, fixed another small bug.

bye,
//mirabilos
-- 
I believe no one can invent an algorithm. One just happens to hit upon it
when God enlightens him. Or only God invents algorithms, we merely copy them.
If you don't believe in God, just consider God as Nature if you won't deny
existence.  -- Coywolf Qi Hunt


[PATCH] Mention -e in print command synopsis

2017-02-27 Thread Jean Delvare
Now that the print command supports option -e and it is documented,
it should also appear in the command synopsis.
---
 mksh.1 |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/mksh.1
+++ b/mksh.1
@@ -3759,7 +3759,7 @@ however, distributors may have added thi
 .Pp
 .It Xo
 .Ic print
-.Oo Fl AclNnprsu Ns Oo Ar n Oc \*(Ba
+.Oo Fl AcelNnprsu Ns Oo Ar n Oc \*(Ba
 .Fl R Op Fl n Oc
 .Op Ar argument ...
 .Xc
-- 
Jean Delvare
SUSE L3 Support


Re: print -R compatibility

2017-02-27 Thread Jean Delvare
Hi Thorsten,

Sorry for the late reply, I have been away from home due to unexpected
family issues.

On ven., 2017-02-17 at 22:37 +, Thorsten Glaser wrote:
> Jean Delvare dixit:
> >Our previous products included ksh93.
> 
> OK. (Found out as well that ksh93 has print -e, which we had code
> for but no member in the getopt call…)

Good catch. As ‘\’ sequences are processed by default, the use cases
for -e must be fairly limited. As I understand it, the only purpose of
the option is to cancel a previous -r, which is kind of a corner case.
That must be why nobody noticed so far. But for compatibility with
other ksh implementations, I agree it is better to support it, so
thanks for having fixed it.

> (...)
> I looked at ksh93 and investigated several approaches and ended
> up codifying “as soon as -R is encountered, we jump into the BSD
> echo (formerly called Debian echo) codepath”.
> 
> This matches ksh93 in that things like a previous -n, -uN, -s, …
> are *not* reset:
> 
> tg@blau:/usr/src/bin/mksh $ obj/mksh -c 'print -u2 -R -42' >/dev/null
> -42
> 
> This allows your use cases:
> 
> tg@blau:/usr/src/bin/mksh $ obj/mksh -c 'print -R -n -4; print -R 2'
> -42

Looks good.

> Parsing after -R like ksh93 does is not supported:
> 
> tg@blau:/usr/src/bin/mksh $ ksh93 -c 'print -Rn foo; print bar'
> foobar
> tg@blau:/usr/src/bin/mksh $ obj/mksh -c 'print -Rn foo; print bar'
> foo
> bar
> 
> But:
> 
> tg@blau:/usr/src/bin/mksh $ obj/mksh -c 'print -R -n foo; print bar'
> foobar

Fair enough. I hope this minor incompatibility won't be a problem for
out customer.

> This will be in the next mksh release.

Thank you very much. I have backported your work to mksh R50 as this is
what our product includes, and will send to our customer shortly for
testing.

-- 
Jean Delvare
SUSE L3 Support