v0.7
Pre-releaseAs 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.
-
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:-
Appear on the same line with
if
. Otherwise it will be considered to be another command, and elvish will complain thatif
does not have enough arguments. -
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 }
-
-
There used to be a special "boolean return value" for functions like
==
oreq
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. -
The
if
andwhile
control structures now take values instead of pipelines (also see #319). Together with 1 and 2, this codeif == $x 1; then echo 1 else echo 2 fi
should now be written as
if (== $x 1) { echo 1 } else { echo 2 }
-
The
for
control structure has been changed to operate on one iterable value, instead of a bunch of values. Thein
keyword is nolonger needed. For example, this codefor x in lorem ipsum; do echo $x done
should now be written as
for x [lorem ipsum] { echo $x }
-
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.