Hacker News new | past | comments | ask | show | jobs | submit login

(author here) Your first and third paragraph seem to be in conflict? I have heard the feedback that an interactive shell and a programming language should be different, which I disagree with.

(For one, shell is already used as a programming language, so the ship has sailed. Also I use shell in the Lisp tradition: build your program up with a REPL.)

But yes Oil is designed to "give the best of both worlds" as you say in the third paragraph.

This recent post will probably give you the best idea of it:

http://www.oilshell.org/blog/2020/01/simplest-explanation.ht...

Rather than

    echo $mystr   # silently splits
    echo "mystr"  # no split
    
In Oil, it's:

    echo $mystr          # no split by default
    echo @split(mystr)   # opt in explicitly

This is enabled with options so existing shell scripts work. Also @split isn't really idiomatic since you would likely use arrays, but it could be useful for porting.

I've also thought of adding a more explicit alternative for glob, but I actually like the shorter syntax here:

    echo *.py 
    echo @glob('*.py')  # not implemented but is consistent
But I'm probably going to implement this safety feature

https://github.com/oilshell/oil/issues/552

to solve the well known issue where files that look like flags can confuse code and data. e.g. 'rm *' with a file named '-rf'.




In "rather than" part

> echo "mystr" # no split

You probably meant to include $

echo "$mystr" # no split

Still, echo is not good for these examples as for it the split doesn't matter and can't be detected, whereas for other commands (or even calls of functions) it indeed can matter.

This example, I think, illustrates the differences between quoted and unquoted use of $name (as present in the current shells) better (to those who aren't familiar with the nuances of shells):

    f() {
        echo "param 1: |$1|"
        echo "param 2: |$2|"
        echo "param 3: |$3|"
    }

    x=
    y="55 66"
    f "$x" "$y"
    echo
    f $x $y

    #Output is:
    #param 1: ||
    #param 2: |55 66|
    #param 3: ||
    #
    #param 1: |55|
    #param 2: |66|
    #param 3: ||


Yes that was a typo (too late to fix it, oops)

BTW, the fact that shell splits and echo joins is VERY confusing to a beginner. For example:

mystr='a b c' # two spaces between each

    $ echo $mystr
    a b c   # why is there only one space?
I think this was "feature" during the times when it was OK to write C code like:

    char line[100];  // truncates lines longer than 100 chars
But it's no longer OK! Filenames contain spaces, etc.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: