[9fans] Inferno shell - Plan9

This is a discussion on [9fans] Inferno shell - Plan9 ; The Inferno shell man page says about a leading caret in a [ ] class: (As this character is special to the shell, it may only be included in a pattern if this character is quoted, as long as the ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: [9fans] Inferno shell

  1. [9fans] Inferno shell

    The Inferno shell man page says about a leading caret in a [ ] class:

    (As this character is special to the shell, it may only be
    included in a pattern if this character is quoted, as long as
    the leading [ is not quoted).

    It seems to me that treating the unquoted leading string [^ as a
    "token" would be a better alternative. Would it be very difficult to
    implement this rather than expect all exclusive classes to start ['^ ?
    I presume it is a question of where in the parsing the [ and ^ take
    precedence?

    ++L


  2. Re: [9fans] Inferno shell

    wrote in message
    news:a6013917637696eaea285a468964b6b6@proxima.alt. za...
    > It seems to me that treating the unquoted leading string [^ as a
    > "token" would be a better alternative.


    But then you'd need to parse [xxxx] and [^xxxx] identically after the
    starting token and still have to record which alternative to use, something
    that is easy to test for as an initial ^ character with only one parsing
    alternative. Is there some reason for messing with it?

  3. Re: [9fans] Inferno shell

    you could do that, but it adds a fair amount of awkwardness
    into the lexer; i'm not sure that's justified. rc uses ~ instead of ^
    for the same reason, which i would have done in the inferno
    shell, except that i wished to re-use the existing filepat module.

    an alternative might be to scan the pattern before passing
    to filepat, substituting [~ by [^; it would be quite simple,
    just add something like the following to patquote()

    if(word[i] == '[' && i < len word - 1 && word[i+1] == '~')
    word[i+1] = '^';

    although that does potentially break some existing shell scripts
    and it's not clear whether ['^'b] should continue to have
    the same meaning.

    i'll do this if there's a consensus...


+ Reply to Thread