As titled. Given the emergence of more convenient scripting language (python), and the relative wonkiness of the syntax in BASH, are there any cases in which shell scripting using the classic BASH syntax is even desirable?
It's 2017. Is BASH shell scripting even relevant anymore?
Other urls found in this thread:
skarnet.org
beacon.nist.gov
twitter.com
Yes, when you don't want to scribble something that just runs a list of commands with 1000 abstractions/
When you're dealing more on system level, rather than opening one or two files and then doing your thing, there are definitely ways in which it's more convenient . And it's more portable, so long as you're using unix.
If you're a Unix system administrator in any capacity, you'll write some bash scripts. bash is ubiquitous, is a resource cost already spent, and has lightweight syntax for most of what you'll want to do.
So should I learn perl 6?
learn it but don't expect to use it
Shell scripts are still the best way to wrap simple automation around other programs. Shells specialize at launching other programs. Even comparing strings is traditionally implemented using the same semantics as launching external programs.
A shell is a user interface. A scriptable user interface is a great thing.
If you aren't careful you can get sucked in. I've written some ghastly shell scripts to do things that were in retrospect way too important to do this way. Past a certain (pretty low) level of complexity, writing good working bug-free shell scripts is hard.
is there something im missing here or is OP just this much of a faggot
but the terminal is a file
Bash is deprecated. Use execline instead. It's more portable, more lightweight, and has limits that keep it clearly for scripting purposes instead of programming thousand line abominations.
skarnet.org
you need a shell to use execline in
When writing scripts in it, no you don't. That's the whole point of the design. Even the execline parser isn't involved after the initial loading step.
...
Take this script into consideration
foo && bar || failout=$?x=$(baz)# $baz can expand into multiple arguments, and we want it to, so we leave it unquotedbix $baz -x $out >>/var/log/bix.log 2>&1
I wouldn't want to replicate this in Python, and I'm a full-time Python programmer professionally. It would only really be alright with Python 3+, so that you've got checked subprocess, otherwise you're building that shit manually, and even then you've got a far more verbose script than the simple bash. When your use-case is executing series of commands with optional IO-redirection, that's exactly what a shell scripting language is made for, and you shouldn't be breaking out of it without a very good reason. It's simple, readable, reliable, portable, and maintainable, and it's fucking everywhere.
Use the best tool for the job. POSIX shell isn't perfect, but it's better at what it does than any other widespread language (excluding situations like languages that simply let you call into the shell, like Perl's backticks), and you can find it absolutely anywhere. As long as you keep in mind what you need and what delivers what you need, you'll be fine, so long that you are cognisant of expanding requirements and are willing to do a rewrite into a more capable language as soon as the shell language becomes insufficient (especially if you ever end up having to deal with any real datastructures or arrays of any sort).
So, yes, it is still relevant and desirable. It will continue to be so until an alternative comes along that's as convenient and readily-available for chaining together tons of other programs in various different ways and checking or otherwise using their outputs.
Let's all be real here; we should all just adopt PowerShell, not even being ironic here. There is nothing wrong with it aside from all error messages being way too verbose, but it's open source so there's nothing stopping people from re-implementing it
unironically this
After they released open source .NET Core thing I wanted to take a look at this 'New, pro-FLOSS, Microsoft' tech. But after few minutes they managed to disappoint me again, those tools contain 'telemety'. I do not trust anything that MS, the wannabe-Googlelike-ad-company, touches any more.
You mean Microsofts reference implementation contains telemetry, this is the entire point of free software
fox changes his spear not his usage?
Not when FISH exists.
That's bullshit. Fish literally stands for "friendly interactive shell". Scripting is not its strength, and when you script it's nice to use a language that people are likely to already have installed.
That's a weird question. Use shell scripting for what it was meant to do: script the shell, i.e. automate entering commands into the shell. It's great for gluing pre-existing things together and getting them to just work. On the other hand, don't stretch it too far or you will be ripping your hair out. Shell scripting is like using duct tape, there are lots of real uses for it, but you would not want to put heavy load on something that's being held together by duct tape.
Powershell is complete dogshit. It combined with other Microturd programs and craplets should make anyone even remotely familiar with Bash and Linux cry tears from laughter. A) Go to ten/seven forums B) Ask the "pros" how to translate a simple bash oneliner to Powershell C) Sit back and watch as they get flustered when they realize they can't do it, or it takes 20 lines D) Bonus points: Tell them everything must be done from shell
I wrote a script to get the latest random numbers from the NIST Randomness Beacon every minute and output it to a file. I challenge anyone to do it in a simpler way. I'd honestly like to see it.
#!/bin/bash# Outputs the latest randomset from NIST's Randomness Beacon to a file every 60 seconds.while truedoecho "Retrieving latest randomset..."echo "$(grep -oPm1 "(?
Can't you just do 'curl | grep > last'
Your code is retarded. You should write it like tha, there is no need for all of these `$()` wrappings.
You want something to happen every N minutes, use cron.
curl beacon.nist.gov