News for hackers. Stuff that matters.
Re:Something about functions in Bash (2017) by sethrin on Thursday July 05, 2018 @08:32PM (#17468043)
I wrote a short book for novices on shell usage, because it is extremely important for developers to know. Bash one-liners are usually even pretty defensible. But I dream about how the world would be if Bash were actually a good scripting language. It compares favorably to csh, and I fear that's about the best you can say for it.
Re:Something about functions in Bash (2017) by AceJohnny2 on Thursday July 05, 2018 @10:00PM (#17468374)
> But I dream about how the world would be if Bash were actually a good scripting language. It compares favorably to csh, and I fear that's about the best you can say for it.

I finally started appreciating Perl after having to write some nontrivial Bash scripts.

(My hierarchy is: default to Bash when my task is mostly running commands. If there's a bit of text-processing or regex required, Perl. If I need any hierarchical datastructures, Python)

Re:Something about functions in Bash (2017) by sethrin on Thursday July 05, 2018 @10:30PM (#17468445)
I think that the simple expression of this might be that Bash is a command language, not a scripting language.
Re:Something about functions in Bash (2017) by ryl00 on Friday July 06, 2018 @02:15AM (#17469332)
What's difficult about hierarchial data structures in Perl?
Re:Something about functions in Bash (2017) by vgy7ujm on Friday July 06, 2018 @05:28AM (#17470061)
Agreed, it's rather one of Perl's strengths.
Re:Something about functions in Bash (2017) by AceJohnny2 on Friday July 06, 2018 @03:30PM (#17474406)
The need for references.
Re:Something about functions in Bash (2017) by 3rdAccount on Thursday July 05, 2018 @10:52PM (#17468515)
Haha, I came to the same conclusions. Perl can do nested data structures, but it ain't easy. With Python, I did it without knowing it was a thing.
Re:Something about functions in Bash (2017) by nerdponx on Thursday July 05, 2018 @10:35PM (#17468463)
You might enjoy Zsh.
Re:Something about functions in Bash (2017) by MaxBarraclough on Friday July 06, 2018 @05:37AM (#17470105)
> It compares favorably to csh, and I fear that's about the best you can say for it.

Ha. Talk about 'damned with faint praise'.

I'm not really in the Unix admin world, but can't you just bite the bullet and use a 'real scripting language' like Python? Other than for things like configure scripts, is the universality of BASH/POSIX really non-negotiable?

Re:Something about functions in Bash (2017) by jacobush on Friday July 06, 2018 @08:08AM (#17470719)
Python has versions
Re:Something about functions in Bash (2017) by MaxBarraclough on Friday July 06, 2018 @10:45AM (#17471784)
Python3 is pretty stable, no?
Re:Something about functions in Bash (2017) by jacobush on Friday July 06, 2018 @10:53AM (#17471876)
It's starting to get there, recently, so I am hopeful Python can be a good alternative to Bash more often nowadays!

There is also the cultural difference. In Python, it's so easy use pip and modules, but if you want something to replace Bash, you need to resist the temptation and only use what's in the standard library. The thing with Bash scripts is that they are often self contained and you can grab a huge snippet of it and it will work pretty much everywhere. (Exceptions of course, the script may do some fancy include or use a program not available, but you get my drift with this.)

Bash has been stable a long time, and the Bourne shell compatible part of it for even longer.

Re:Something about functions in Bash (2017) by vageli on Saturday July 07, 2018 @12:36PM (#17479241)
> There is also the cultural difference. In Python, it's so easy use pip and modules, but if you want something to replace Bash, you need to resist the temptation and only use what's in the standard library.

I don't think it's fair to say that bash programs are not without dependencies, just that the developers (tended to be?) are more thoughtful about portability. For example I've seen scripts that use wget or fall back to curl when it's not available. I've never seen a python script fall back to urllib3 when requests wasn't available on the system.

Re:Something about functions in Bash (2017) by jacobush on Monday July 09, 2018 @05:07AM (#17488901)
Well, culture. Python could be programmed to fallback to urllib3. Bash could have a package manager and virtual environments.

Hm... I wonder if that is a good idea or a horrible one... :)

Re:Something about functions in Bash (2017) by jonnydubowsky on Friday July 06, 2018 @12:42AM (#17468885)
I'd love to know more about the book!
Re:Something about functions in Bash (2017) by sethrin on Saturday July 07, 2018 @02:37AM (#17477387)
The focus is on usage as opposed to scripting, and it was written in a few days as a somewhat visceral reaction to seeing a single-page introduction to the shell in a coding academy. It may be that the term "booklet" is more appropriate than "book", and it is certainly the case that "wrote" in the context above should not imply "edited" or "published". However, at the moment I am between projects, and I am very happy to take your interest as a spur to complete this work. However, if you had some time to indulge, I might be able to repay your interest somewhat sooner; having other people review one's final copy is probably the next thing to a necessity.