News for hackers. Stuff that matters.
Re:Bash $* and $@ (2017) by chubot on Sunday January 12, 2020 @02:24PM (#22028540)
Oil [1] supports all of this old syntax to run existing shell scripts, but has new syntax which is more convenient.

- You can write @ARGV instead of "$@".

- You can write @myarray instead of "${myarray[@]}"

(Related: Thirteen Incorrect Ways and Two Awkward Ways to Use Arrays https://www.oilshell.org/blog/2016/11/06.html )

Example:

    oil$ var myarray = @('has spaces' foo)
    oil$ var s = $'has\ttabs'

    # function to print an array element on each line
    oil$ lines() { for x in @ARGV; do echo $x; done }

    # pass 3 args -- 2 from myarray and 1 from s
    oil$ lines @myarray $s
    has spaces
    foo
    has     tabs
[1] https://www.oilshell.org/
Re:Bash $* and $@ (2017) by dzidol on Sunday January 12, 2020 @03:09PM (#22028894)
Re:Bash $* and $@ (2017) by chubot on Sunday January 12, 2020 @04:22PM (#22029509)
Unlike every other alternative shell, Oil runs existing bash scripts to avoid this problem.
Re:Bash $* and $@ (2017) by XelNika on Sunday January 12, 2020 @08:13PM (#22031052)
I don't really think Oil is relevant to this topic. The only good reason I can think of for someone to script in bash is for portability purposes. If someone wanted portability without bash's shitty syntax, something like Python would be a much better candidate than Oil. One could also argue that there's no meaningful difference between e.g. fish scripts and Oil scripts because neither will work on the standard shell. It's also possible to run bash scripts from fish by simply calling bash. Right now, Oilshell is a reasonable choice for an interactive shell with bash compatibility, whereas Oil syntax is just as, if not more, useless for public distribution as fish.

As I see it, the goal for a project like Oilshell (a shell with both a new syntax and support for standard bash syntax) would be to replace bash as the default shell in distros. Until then, Oil scripts lack the primary feature of bash scripts just like other alternative shells.

Re:Bash $* and $@ (2017) by chubot on Sunday January 12, 2020 @09:19PM (#22031315)
the goal for a project like Oilshell (a shell with both a new syntax and support for standard bash syntax) would be to replace bash as the default shell in distros.

Right, that's the goal of Oil.

Re:Bash $* and $@ (2017) by XelNika on Monday January 13, 2020 @04:57PM (#22039166)
Right, so what's the point in switching to Oil as a scripting language when that hasn't happened?
Re:Bash $* and $@ (2017) by nvllsvm on Sunday January 12, 2020 @08:55PM (#22031226)
Funny you mention Python being a better candidate than Oil as Oil is built a top a fork of Python 2. https://www.oilshell.org/blog/2018/03/04.html#faq