Loads of interesting features in this release of ABS, spearheaded by require(file)
, ~/.absrc
and background commands -- let's get to it!
Features
- you can now add default functions / configurations into the
~/.absrc
and ABS will pre-load this file when it runs (#188) - as part of the same changes (#188), we added the functionality to include files into your scripts by using
source(path/to/file)
orrequire(path/to/file)
- you can play around with your prompt by setting the environment variables
ABS_PROMPT_LIVE_PREFIX=true
andABS_PROMPT_PREFIX=templated_string
. Thetemplated string
can use{dir}
,{user}
,{host}
that will be replaced on-the-fly. For further info, have a look at the sample .absrc file
$ ABS_PROMPT_LIVE_PREFIX=true ABS_PROMPT_PREFIX="I am in {dir}" abs
Hello alex, welcome to the ABS (1.2.0) programming language!
Type 'quit' when you're done, 'help' if you get lost!
I am in ~/projects/abs
- background commands (#70) have landed: when a command ends with a
&
ABS will execute it in background, without blocking your script (`sleep 10 &` && echo("hello")
). In order to "gain control back" and wait for a background command to finish you just have to callwait()
on the command. Thedone
property of a command can be used to understand whether a command has finished or not
cmd = `sleep 10`
echo("This will be printed in 10s")
cmd = `sleep 10 &`
echo("This will be printed immediately")
sleep(9000)
cmd.done # FALSE
cmd.ok # FALSE
echo("We have been waiting 9s")
cmd.wait()
echo("And approximately another second")
cmd.done # TRUE
cmd.ok # TRUE
- added the
floor()
,round(n)
,ceil()
methods for numbers (and strings that can be auto-converted to numbers)
10.9.floor() # 10
"a".floor() # ERROR: floor(...) can only be called on strings which represent numbers, 'a' given
"10.9".floor() # 10
10.3.ceil() # 11
"a".ceil() # ERROR: ceil(...) can only be called on strings which represent numbers, 'a' given
"10.3".ceil() # 11
10.3.round() # 10
10.6.round() # 11
10.333.round(1) # 10.3
"10.333".round(1) # 10.3
"a".round() # ERROR: round(...) can only be called on strings which represent numbers, 'a' given
- the ABS repl now supports history through the
~/.abs_history
file (#172) - implemented the
cd(dir)
function, that optionally cds into the user's home if called without arguments (#155)
Bugfixes
- fixed a few random panics when calling builting functions without enough arguments (#193)
- windows commands are now using
cmd.exe
rather than bash, as bash might not be available on the system (#180) - better error messages when parsing "invalid" numbers (#182)
- the ABS installer was not working with wget 1.20.1 (#178)
- the ABS parser now supports numbers in scientific notation (eg.
8.366100560806463e-7
, #174) - errors on builtin functions would not report the correct error line / column numbers (#168)
Thanks
Endless of thanks to @ntwrick, the real mastermind behind most of the features that landed in this release of ABS! And to @andromedarabbit for his help in fixing the installer!