[9fans] termrc changes - Plan9

This is a discussion on [9fans] termrc changes - Plan9 ; What is the effective change made in termrc between the old version: disk='' if(test -f /dev/sd*/swap) disk=`{ls /dev/sd*/swap >[2]/dev/null | sed 1q | sed 's!swap$!!'} if(! ~ $disk '') { swap $disk^swap >/dev/null >[2=1] dossrv c: } and the new ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: [9fans] termrc changes

  1. [9fans] termrc changes

    What is the effective change made in termrc between the old version:
    disk=''
    if(test -f /dev/sd*/swap)
    disk=`{ls /dev/sd*/swap >[2]/dev/null | sed 1q | sed 's!swap$!!'}
    if(! ~ $disk '') {
    swap $disk^swap >/dev/null >[2=1]
    dossrv
    c:
    }
    and the new one:
    # start up local swapping, mount dos fat fs
    disk=`{ls /dev/sd*/swap >[2]/dev/null}
    if (! ~ $#disk 0) {
    swap $disk(1) >/dev/null >[2=1]
    dossrv
    c:
    }
    rm /env/disk
    is it just an elimination of ‘test’s or something more substantial?

    --Joel


  2. Re: [9fans] termrc changes

    The new termrc avoids using test when looking for swap partitions.
    The old termrc sometimes invoked test as

    test -f file1 file2

    which is incorrect, though tolerated by the new test command because
    of the need to tolerate unprocessed arguments in the presence of
    short-circuit -a and -o evaluation. If test were modified to process
    all its arguments at the start (presumably building an expression
    tree), it could then complain about excess arguments again.


  3. Re: [9fans] termrc changes

    > If test were modified to process
    > all its arguments at the start (presumably building an expression
    > tree), it could then complain about excess arguments again.


    I have a modified version of test which uses a parameter for e(),
    e1(), etc to determine whether sub-expressions should be evaluated
    or just parsed. This allows the whole test command to be checked
    for syntax, while preserving the lazy semantics ("short circuit")
    of -a and -o.

    I haven't submitted it because it seems somehow clunky.

    A much simpler change would be just to have -a and -o behave like &
    and | instead of like && and ||; in other words, to perform both tests
    (and therefore syntax check the whole command) before combining the
    boolean results. I've looked at the posix description of test and it
    doesn't actually say that -a and -o have to be lazy. Would this cause
    any problems in practice?

    -- Richard


+ Reply to Thread