Jean Delvare dixit:

>I din't think -R currently emulates either properly (but I suppose I
>can't complain, as "to some degree" could be read as implying just
>that.) BSD echo will print arguments starting with a dash, other than a

Hmm, okay. In that case (I’ll recheck with legacy BSD sources though)
I’ll likely change the behaviour.

>leading -n. So if "print -R -42" is supposed to be like BSD "echo -42",
>it should print "-42", as is the case with legacy ksh.

That’s ksh88 where you(r customer) come(s) from?

>> We have the echo you mean in POSIX mode though…
>
>Not sure what you mean here. I see that the echo command behavior is
>changed if Flag(FPOSIX), but I can't seem to be able to set that flag
>(I tried "export POSIX=1" but that doesn't seem to change anything?)

“set -o posix” ;-)

>Also that would only change the behavior of echo anyway, not print.

Yes, of course.

>Actually I already suggested to the customer that they could replace
>all the instances of "print -R" by "print -r --" in their scripts. They
>did not answer yet.

If it’s that easy…

>I believe "print -r --" is a better choice in general regardless of the

(yes, it is)

>outcome of our discussion, as -R will treat -n and -e (and combinations
>thereof) as options, and the user may not expect that.

… depends on what the user wishes, but if they really only want to
echo out arbitrary strings, “print -r -- "something"” is the way to go.

>I agree, and I would go that way if it was my code (straight to step 2,
>even.) But it's not, and my experience is that customers are often
>reluctant to change scripts that have been running for a long time and
>are still deployed on many, sometimes heterogeneous, systems. I can
>make suggestions but they get to make decisions.

I *completely* understand, having a dayjob in IT as well.

>I did suggest to them to just use "echo" at one point and they turned
>it down exactly because of portability concerns. Their script is
>running on different OS flavors where echo behaves differently. They

True.

>> Hrm. Funnily enough:
>>
>> tglase@tglase-nb:~ $ print -R -- -42
>> -- -42
>> tglase@tglase-nb:~ $ print -R -x -42
>> /bin/mksh: print: -x: unknown option
>
>I did notice this inconsistency too as part of my investigation, and
>that's one of the reasons why I'm not sure the current behavior is
>really by design.

I noticed that mostly after writing the rest of the mail, which is why…

>> Perhaps I’ll have to investigate “the BSD echo(1) command”
>> further (no problem thanks to TUHS) and maybe the implementation
>> is indeed wrong… but the result will likely end up in a formal
>> mksh release too late for your customer anyway. I’ll make a note.

I wrote that.

>That would not be a problem. If I know for sure that such a change will
>make it into a future release of mksh, I can backport the change
>immediately to whatever version our customers are running.

OK.

>For reference, here is the patch I came up with. The idea is to jump to
>the "echo" command handling code a soon as we see -R. The rest of the
>changes is to remove po.pminusminus as it is no longer needed. Known

That’s about what I’d have done as well (unless the BSD echo
behaves different from classical echo in which 'print -R -ex'
would be the same as 'print -r -- -ex'; the alternative would
be to parse the -e from -ex and only then output it, turning
it into 'print -- -ex'). This is why some investigation is
likely still needed.

If I take your patch, do you wish to have your name added to
the list of copyright holders at the top of the file?

>caveat: -E would be handled as a valid option, while it was not

True, but that can be circumvented.

>supported by print -R before. Actually legacy ksh only supports -n
>after -R (as BSD echo does), not -n nor -E.

Which one are you coming from, again? ;)

bye,
//mirabilos
-- 
13:22⎜«neurodamage» mira, what's up man? I have a CVS question for you in #cvs
13:22⎜«neurodamage» since you're so good w. it │ «neurodamage:#cvs» i love you
13:28⎜«neurodamage:#cvs» you're a handy guy to have around for systems stuff ☺
16:06⎜<Draget:#cvs> Thank god I found you =)   20:03│«bioe007:#cvs» mira2k: ty
17:14⎜<ldiain:#cvs> Thanks big help you are :-)   <bioe007> mira|nwt: ty again

Reply via email to