From owner-freebsd-questions@freebsd.org Fri Feb 3 22:25:53 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 C6A7BCCF1C1 for ; Fri, 3 Feb 2017 22:25:53 +0000 (UTC) (envelope-from byrnejb@harte-lyne.ca) Received: from inet08.hamilton.harte-lyne.ca (inet08.hamilton.harte-lyne.ca [216.185.71.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "inet08.hamilton.harte-lyne.ca", Issuer "CA_HLL_ISSUER_2016" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 8AF27D39 for ; Fri, 3 Feb 2017 22:25:53 +0000 (UTC) (envelope-from byrnejb@harte-lyne.ca) Received: from localhost (localhost [127.0.0.1]) by inet08.hamilton.harte-lyne.ca (Postfix) with ESMTP id A709762305; Fri, 3 Feb 2017 17:25:51 -0500 (EST) X-Virus-Scanned: amavisd-new at harte-lyne.ca Received: from inet08.hamilton.harte-lyne.ca ([127.0.0.1]) by localhost (inet08.hamilton.harte-lyne.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rS5J0JP5aSew; Fri, 3 Feb 2017 17:25:46 -0500 (EST) Received: from webmail.harte-lyne.ca (inet04.hamilton.harte-lyne.ca [216.185.71.24]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by inet08.hamilton.harte-lyne.ca (Postfix) with ESMTPSA id E2C85622FA; Fri, 3 Feb 2017 17:25:45 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=harte-lyne.ca; s=dkim_hll; t=1486160746; bh=5HCPmqqUAHPpyMx3ZkjIeL3XcNiipc33PaPIhYjcuoE=; h=In-Reply-To:References:Date:Subject:From:To:Cc:Reply-To; b=KV0L3FkArlleogyUqmYAd7YfZNODZaHKWe3PZSXkZwzqUfcNsXG9V8sS8LVA6IOHA DE40FUqSiazfIZu8G6W7SnQ7yzJiELF57D36pm7on3Al3OaJyI7Qt6qLk6+v3W01q5 jI99BxEqDkk/S6gTTLqXwEnV2RRzfYrK8nreACba6ccpHgZ/FaDHnxiu5FxGFcKFiZ UXSKrB4w9kYZtNMUZWod7PM3yp45MHRxgfquL2DsrxRLPLUNFnOBy4Lv5kJs0VW7y/ QEWqFe0b4h3BylhnaNO6E6kDIKtpLBpi4qDs3WMWLF+rWFveja8FPPz8elz0ccHtvi ItcuXqiO8yXNg== Received: from 216.185.71.44 (SquirrelMail authenticated user byrnejb_hll) by webmail.harte-lyne.ca with HTTP; Fri, 3 Feb 2017 17:25:46 -0500 Message-ID: <7df89058c8e1c2078611909cdb150e4c.squirrel@webmail.harte-lyne.ca> In-Reply-To: References: Date: Fri, 3 Feb 2017 17:25:46 -0500 Subject: Re: Variable assignment in sh From: "James B. Byrne" To: "Garance A Drosehn" Cc: "Polytropon" , freebsd-questions@freebsd.org Reply-To: byrnejb@harte-lyne.ca User-Agent: SquirrelMail/1.4.22-4.el6 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal 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: Fri, 03 Feb 2017 22:25:53 -0000 On Wed, February 1, 2017 19:21, Garance A Drosehn wrote: > > On something of minor tangent, if you're writing scripts in either > 'sh' > or 'bash', you may find the following web site helpful: > I just wish to clarify something here. What I am doing is attempting to reuse a one-liner that has one conditional in it. I do not consider that to be scripting or programming. I am just piping a few tools together and checking if anything comes out the end. I have written bash scripts of course, but those things tend to look like this: #!/usr/bin/env bash SCRIPT_NAME=$(basename $0) VERSION=1.01.001 AUTHOR="byrnejb@harte-lyne.ca" DATE_CREATED="2011-Jun-03" DATE_UPDATED="2011-Jun-03" # Maximum number of arguments allowed by this program MAXARGS=99 # Minimum number of arguments required by this program MINARGS=0 SCRIPT_PATH=$(dirname $0) usage() { cat >&2 << EOD Version: $VERSION Usage: $SCRIPT_NAME [options] [arguments] # Purpose of script: # This is a script template with examples of getopts usage # This script supports the following options: OPTIONS: -h Show this message and exit with failure status 2 -a=value set option a to value -b=value set option b to value -d=level set debug level to level . . . Today when I script then I tend to use Ruby. Tomorrow? Who knows? -- *** e-Mail is NOT a SECURE channel *** Do NOT transmit sensitive data via e-Mail Do NOT open attachments nor follow links sent by e-Mail James B. Byrne mailto:ByrneJB@Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3