From owner-freebsd-questions@freebsd.org Wed Oct 11 23:02:01 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43C2DE39B12 for ; Wed, 11 Oct 2017 23:02:01 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (wonkity.com [67.158.26.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "wonkity.com", Issuer "wonkity.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 1826480DF0 for ; Wed, 11 Oct 2017 23:02:00 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.15.2/8.15.2) with ESMTPS id v9BN1tw1090262 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 11 Oct 2017 17:01:55 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.15.2/8.15.2/Submit) with ESMTP id v9BN1t1J090259; Wed, 11 Oct 2017 17:01:55 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Wed, 11 Oct 2017 17:01:55 -0600 (MDT) From: Warren Block To: Paul Pathiakis cc: Paul Schmehl , Polytropon , "freebsd-questions@freebsd.org" Subject: Re: Scripting problem In-Reply-To: <1984508980.4145408.1507553196491@mail.yahoo.com> Message-ID: References: <7AB396F429EEB6890100F082@Pauls-MacBook-Pro.local> <8C8E7D66788801594EC0FC4C@Pauls-MacBook-Pro.local> <20171008100017.30ab5987.freebsd@edvax.de> <88D321A2CCD516AEF39DE8C3@Pauls-MacBook-Pro.local> <1984508980.4145408.1507553196491@mail.yahoo.com> User-Agent: Alpine 2.21 (BSF 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (wonkity.com [127.0.0.1]); Wed, 11 Oct 2017 17:01:55 -0600 (MDT) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 23:02:01 -0000 On Mon, 9 Oct 2017, Paul Pathiakis wrote: >> Quoting is sh's biggest weakness. Well, that and lack of basic data >> structures, and the weak logical structures, and so on. > > ### Well, yes and no. I consider it both a strength and a weakness. I find sh to be exactly what I think of a scripting language to be... glue. I don't > expect to write a fully versed program in sh. I wouldn't be using sh for that. I find sh to be that 'tool' to use when I want to call other tools and > utilities. (sed, awk, tr, etc) > > ### I think people have gone way too far in creating 'scripting' languages that are more programming languages than scripting.... Personally, I tried > learning PERL which tries to be everything to regex. The problem? Lack of coherence... "I can do this 5 different ways in PERL" Is that supposed to be a > good thing when all five seem to execute at different speeds, using different resources, etc? (apologies to Larry Wall and the rest) The multiple domains that are utterly different are not just in Perl. In sh, you can use sed and awk, which have very little overlap. In fact, you pretty much have to use sed *and* awk, because each is not quite powerful enough to do particular jobs. Or use Perl, which is a superset of both. The trouble with sh is that it is so weak that it takes a lot of code to accomplish anything. That comes back to haunt the programmer in the long term, because simpler, shorter programs that use more powerful constructs are much easier to maintain. Perl is much-maligned, but every time I rewrite a shell script in Perl it gets shorter and easier to maintain. Or longer and more powerful. Python and Ruby are similar. >> Someone once said that if a script is longer than twenty lines or so, >> it probably ought to be done in a real scripting langugage. That was >> me, but Stephen Bourne has also said it. Yes, that Stephen Bourne. > > ### I'll go off a little on this with kind of a corollary.... No sh script should be more than 20 lines, however, I typically will call shell scripts from > other scripts. But I do agree, if you want to program, use a programming language. (IMHO, C is still the best, most powerful language around but, again, > read a book, talk to the people who are in the know - My 'C' guru is a guy who has written code that utterly shocked me in its elegance, execution, and > simplicity - and the occasional "You can do something like that in C?" thoughts running through my head.) The distinction between programming and "scripting" has always been artificial to me. You write a series of instructions for a computer, that's a program. Give me powerful tools, I'm not interested in doing it the hard way to build character. I have enough character. What I want back is the time I spend trying to fix sh scripts.