Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Incorrect evaluation of ~ test in ternary conditional
- X-seq: zsh-workers 42205
- From: Felix Uhl <felix.uhl@xxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Incorrect evaluation of ~ test in ternary conditional
- Date: Wed, 3 Jan 2018 10:44:42 +0000
- Accept-language: de-DE, en-US
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- In-reply-to: <CAH+w=7aguzBsj76z6Bt6o8a6i_2UyzFPh07rjUnfAE1LLNW0UQ@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <DB6P194MB0037AE570D0106FB365F3C549D0B0@DB6P194MB0037.EURP194.PROD.OUTLOOK.COM> <CAH+w=7YRkk+Ofnf-HyfmGXZdqO_3OVBCxXusAGEQhVS8+jTcGw@mail.gmail.com> <DB6P194MB00376583089F5F424CEB64C19D0E0@DB6P194MB0037.EURP194.PROD.OUTLOOK.COM> <CAH+w=7aguzBsj76z6Bt6o8a6i_2UyzFPh07rjUnfAE1LLNW0UQ@mail.gmail.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
- Thread-index: AQHTdaxOCnrC+8lS2UuLQjsbyOJJ9aNGh2SAgAKxNYCAEgs/gIAG0IYA
- Thread-topic: Incorrect evaluation of ~ test in ternary conditional
On 30.12.2017 03:40, Bart Schaefer wrote:
> Catching up on some old stuff ...
>
> On Mon, Dec 18, 2017 at 7:07 AM, Felix Uhl <felix.uhl@xxxxxxxxxx> wrote:
>>> - if (*ss++ == '/' && *ss)
>>> + if (*ss && *ss++ == '/' && *ss)
>>> arg--;
>>>
>>> I'm not sure whether (*ss == '/' && *++ss) would be equivalent, i.e.,
>>> I don't know why the original formulation skips over the first
>>> character whether or not it is a '/'. Possibly to skip a leading '~'?
>> The original implementation doesn't skip the first character, does it?
> It does, because it increments ss regardless of whether or not the
> first character is '/'. So if ss = "a", (*ss++ == '/' && *ss) is
> false because 'a' != '/', but ss now points at '\0' instead of at 'a'.
>
>> Did you actually test it?
> Yes.
Ah, you're absolutely correct. Thanks for the explanation!
I guess the only thing left then is to find out whether your fix breaks
anything, correct?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author