github elves/elvish v0.7

latest releases: v0.20.1, v0.20.0, v0.20.0-rc4...
pre-release5 years ago

As always, binaries are on dl.elvish.io.

Breaking changes

Almost all the breaking changes are about control structures. If you have scripts written for 0.6 or earlier, you can use fix-for-0.7 to upgrade your scripts automatically.

  1. Control structures used to mimic POSIX shell, but now use curly braces in a Go-like style:

    if (eq a a) {
        echo foo
    } else {
        echo bar
    }
    

    Note that in the above code, the opening brace { must:

    1. Appear on the same line with if. Otherwise it will be considered to be another command, and elvish will complain that if does not have enough arguments.

    2. Have a space before it. Otherwise it will be parsed as brace expansion (as in echo {a,b}{c,d}) instead.

    The newline after { can be substituted by a space, so you can write these in one line if you must:

    if (eq a a) { echo foo } else { echo bar }
    
  2. There used to be a special "boolean return value" for functions like == or eq to indicate whether it has succeeded or failed, indicated by � when failure happens. Now they simply output a boolean value $true or $false (#319).

    The ?(...) operator used to capture the aforementioned "boolean return value". Use the output capture operator (...) instead. The ?(...) operator has been repurposed to capture exceptions.

  3. The if and while control structures now take values instead of pipelines (also see #319). Together with 1 and 2, this code

    if == $x 1; then
        echo 1
    else
        echo 2
    fi
    

    should now be written as

    if (== $x 1) {
        echo 1
    } else {
        echo 2
    }
    
  4. The for control structure has been changed to operate on one iterable value, instead of a bunch of values. The in keyword is nolonger needed. For example, this code

    for x in lorem ipsum; do
        echo $x
    done
    

    should now be written as

    for x [lorem ipsum] {
        echo $x
    }
    
  5. The try control structure is only changed syntactically. This piece of code:

    try
        do-dangerous-stuff
    except e
        put $e
    else
        echo all well
    finally
        echo finally
    tried
    

    is now written as:

    try {
        do-dangerous-stuff
    } except e {
        put $e
    } except {
        echo all well
    } finally {
        echo finally
    }
    

Notable enhancements

A but: glob qualifier has been introduced to exclude results from globbing. For instance, to remove all files in the current directory except parse, do:

rm -r *[but:parse]

The qualifier only accepts literal file names for now.

Don't miss a new elvish release

NewReleases is sending notifications on new releases.