Deutsch English Français Italiano |
<vfmldv$ll5i$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.unix.shell Subject: Re: [ksh93u+m] Performance warning message Date: Mon, 28 Oct 2024 01:21:17 +0100 Organization: A noiseless patient Spider Lines: 48 Message-ID: <vfmldv$ll5i$1@dont-email.me> References: <vff7qe$31ohp$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Mon, 28 Oct 2024 01:21:19 +0100 (CET) Injection-Info: dont-email.me; posting-host="f95b327adceab14f91e2f2628e068817"; logging-data="709810"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IaWDzdOXDUgXmYKd9tAKl" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cancel-Lock: sha1:5tQwAOaximFHkg0UpY01lm15F6Q= X-Enigmail-Draft-Status: N1110 In-Reply-To: <vff7qe$31ohp$1@dont-email.me> Bytes: 2698 On 25.10.2024 06:46, Janis Papanagnou wrote: > For this command > > typeset -i indents=$(( level * indent_factor )) ### > > with two integer variables, 'level' and 'indent_factor', declared > I'm getting this nice warning message > > warning: line 28: indents=$(( level * indent_factor )) > is slower than ((indents= level * indent_factor )) > > I thought (to avoid the warning) I'd have to split the lines like > > typeset -i indents > (( indents = level * indent_factor )) > > but I noticed that we can also write > > (( typeset -i indents = level * indent_factor )) > > (I wasn't aware about the 'typeset' command possible in arithmetic > expressions.) Oops! - That's wrong. - I had just tested that only with 'ksh -n'. ksh -n had produced the above performance warning message, but it did not produce an error message for the (( typeset ... )) syntax, which I saw just now when invoking the shell regularly on the code. This is really odd (shell-)behavior! (Reporting a warning but not an error.) - Looks like a bug to me.[*] So we have to either use the "non-performant" syntax marked '###' or separate the statements on two lines. > > Though I wonder why Ksh doesn't silently optimize the '###' marked > code since Ksh optimizes so many less obvious and much more complex > things. > > Janis [*] The man page says for option '-n': "Read commands and check them for syntax errors, [...]" So the warning message is just an undocumented feature for free? And the 'typeset' inside the arithmetic command is syntactically okay and deserves no diagnostic message?