Variable assignment in sh

James B. Byrne byrnejb at harte-lyne.ca
Fri Feb 3 22:25:53 UTC 2017


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="<James B. Byrne>byrnejb at 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 at 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



More information about the freebsd-questions mailing list