universal-shell / wip Goto Github PK
View Code? Open in Web Editor NEWA *work-in-progress* non-posix modern unix shell.
A *work-in-progress* non-posix modern unix shell.
String, Array, Map, Set?
Special syntax to distinguish different variables?
Other than isolation of context, namespace is not that useful without a way to create short aliases.
This news is very encouraging: https://channel9.msdn.com/Events/Build/2016/C906
I'm waiting for the next Windows 1y. 😛
Since the shell supports map/dictionary type, maybe it is nice to have this functionality applied to user-defined funtions too.
printf
, quote
and regex
are three must-haves.
Completely possible and for mental health
For example:
@echo $num
output:
echo $num
42
Workflow of the shell: Shell Script -> AST (-> Bytecode?) -> LISP VM (-> JIT?) -> Evaluation
bash has sparse arrays. That's to say you can assign to an array with an index out of bound:
x=(1 2 3)
x[7]=8
x[5]=6
echo ${x[@]} #=> 1 2 3 6 8
Sparse arrays can be implemented as an ordered map.
bash also has associative arrays which are indexed with arbitary strings, but they are unordered maps.
declare -A y=([1]=1 [2]=2 [11]=11)
echo ${y[@]} #=> 11 1 2
We can unified sparse arrays and associative arrays into ordered maps, with all elements (or just values with numeric keys) numeric-sorted.
References:
"balance"
How to express line continuation? Where is it allowed?
By default, functions need local scopes. We can provide a way to create local scopes too.
Also, sometimes environment variables need to be exported to sub-process.
What shall we do when:
How to query the attributes of a variable?
And how to copy the attributes from one variable to another?
Bash style: echo 2>&1
where 2 is a file descriptor for standard error output, not plain text "2".
How to avoid these with least special symbols?
And what is the final exitcode?
Pseudo-code:
print $(code 1) $(code 2)
code 1 | code 0
ignore $(code 1) | code 0
define x $(code 1) | code 0
How to do that with minimal syntax? For set/get/apply/...
Pattern matching for arrays/maps?
Some cool ideas.
Thread->Fork (libuv), or Fork->Thread (boost.asio), this is a problem?
Just a reminder before everything is done.
Also remember to flush the buffers:
#include <stdio.h>
#include <unistd.h>
int main(void) { printf("foo"); /* fflush(stdout); etc */ fork(); return 0; }
Interesting:
Very interesting:
... and never have any special effect when escaped.
Stop messing with the exitcodes of executables.
<tab> <space> <newline>
?
<nul>
?
Reinvent IFS? Phewwwwwwwwww…
There must be jobs running in the background.
How to support nested conditions gracefully, without sacrificing ease of typing?
Windows' cmd.exe is interesting. Some commands such as echo
, pushd
, popd
, goto
, when running successfully, do not modified the exit code (%ERRORLEVEL%
) of the previous command.
This feature is not only useful to the goto
command, but also let the user provide well-written information about the running status with echo
without having to store and restore the previous exit status.
Even without an option to exclude dot-files?
When should a wildcard (*
) expanding to nothing emit an error (failglob), when not (nullglob)?
Cases:
rm a c* e
ls file{*.bak,.exe,.log}
x=*
for i in *
bash is confusing because it provides test
, [ ... ]
and [[ ... ]]
for the same purpose: check file types and compare values.
There should only be one proper way to do that.
First principles:
How to deal with exceptions? Abort or Ignore?
What should we do if the GNU/BSD/… coreutils (ls, mv, cp, …) do not cope well with the shell when dealing with symlinks?
Integer calculation is important for manipulating arrays and batch output.
Big integer (unlimited precision) calculation is good and easy to implement. Must-have: addition, subtraction, multiplication, division, modulo op, power op.
This is not necessary, but seems helpful and interesting. The main purpose is to liberate the maintainers from writing ugly shell scripts with dirty hacks spread everywhere.
Something like parallel { ping; pong; }
?
Nowadays, Unicode (UTF-8, UTF-16, UTF-32, …) is the most widespread encoding standard which is also compatible with ASCII.
Among different encoding methods of Unicode characters, UTF-8 is most suitable for byte values manipulation and sorting.
References:
Simple is Best
By default, a glob with no match will spill an error. A "null glob" does not.
So, how about making an empty variable throw an error while expanding?
It could be quite good to defer some clean-ups, so that we don't have to put tangled logic in the script.
where the fun begins
How to cut more connections to the operating systems?
/
as path separators, .
as "the current directory", ..
as "the parent directory", /
at the start as "the root path of the local file system".#
as the comment starter?env 🇪🇺=Europe
?May the BIOS clock reset no ruin your life.
Even though the fishy heads have poor memory, good documentation is still needed. We don't need thousands of indicators at the prompt to make the brain clunkier.
To refine chaining of commands, let's see what is necessary to achieve here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.