Re: Are there any plans for more readable, modern syntaxes for If statements?

2020-03-29 Thread John W
On 3/26/20, George  wrote:
> On Thu, 2020-03-26 at 19:05 +0200, Vaidas BoQsc wrote:
> I think shells would really benefit from things like
> more powerful data structures, better facilities for passing complex data
> to, and parsing complex data from different programs, better scoping,
> better file handling, and clean-up of various language and implementation
> details that currently tend to trip people up.

I can almost hear the same thoughts going through Larry Wall's head 30+
years ago (:

> $ some_command -file1 $fd1 -file2 $fd2 {fd1}<./first_file
> {fd2}<./second_file
>
> to work as a substitute for this:
>
> $ exec {fd1}<./first_file {fd2}<./second_file# open files, store file
> descriptor numbers in parameters
> $ some_command -file1 $fd1 -file2 $fd2
> $ exec {fd1}<&- {fd2}<&- # close files
>
> That is, open the files just for the command being run (because that's how
> redirections work) and make the parameters storing the file descriptor
> numbers available before expanding parameters in the command, so you can
> pass them to the command.

Are you familiar with Bash's <(...) syntax?
Your example could be written (if I understand right):

  $ some_command -file1 <(cat ./first_file) -file2 <(cat ./second_file)

Though that doesn't store the descriptors in variables.

Personally, I've found that I've grown into shell syntax over the years.
I certainly went through phases where it felt strange and clunky (and some
parts genuinely are, to be sure), but I have come to appreciate more of
the design choices and less-known features over time.

One day I may even read the entire manual page and understand it!



Re: Are there any plans for more readable, modern syntaxes for If statements?

2020-03-29 Thread Ahmed Rahal
Le 20-03-26 à 14 h 28, Daniel Colascione a écrit :
>> I keep on wondering why these shells can't come up with something better
>> than improving previous shell syntax by little by only providing poor
>> better alternatives.
>> I somehow think there is a need to rethink shells from scratch to make
>> them
>> less mentally demanding and readable in the command prompt and scripts
>> themselves.
>> I really haven't seen anything that I would like to use so far. Neither
>> zsh, tcsh or any other of the more popular ones as far as I remember from
>> the last weeks "personal research".
>>
> fish shell and powershell are two reasonable attempts. I think current
> shell syntax is fine though.
>
>
Just wanted to second this.
If in need for a more complex approach to shell, try Powershell, but
IMHO this is not that more readable.
For readability, forget about shells, go python. It's more readable and
'complete'.
I write this, yet can say that cleanly written bash is as readable as
python, yet python enforces readability, while shells do not.
Truth is that despite all efforts I've seen in the last ... 30 years,
the same issues keep popping.
Clear intent in the language structure, ease of adoption, complexity in
the syntax,  there are so many dimensions you'd want to improve on.
None can have them all. It's probably inherent to the problem at hand.
The trade-offs are the landmarks for each shell/language. As such I'm
afraid that the better really is the enemy of the good.
Besides ... https://xkcd.com/927/

Cheers,

Ahmed.