Sponsored Content
Top Forums Shell Programming and Scripting Tip: template for a safe and portable script Post 303032522 by MadeInGermany on Tuesday 19th of March 2019 02:47:02 PM
Old 03-19-2019
Tip: template for a safe and portable script

In an attempt to finally end this article I start this new thread.
Here is a template for a safe and portable script.
Code:
#!/bin/bash
# /bin/bash exists on most still supported Unixes
#
# tr and date behave better with
if [ -n "$LC_ALL" ]; then export LC_ALL=C; else export LANG=C; fi
#
# Unix optional packages install in
opt_path=/usr/local/bin
solaris_opt_path=/usr/sfw/bin:/opt/csw/bin
#
# set PATH so no PATH is inherited, export it to all children
# Solaris is Posix-compliant in /usr/xpg4/bin and BSD-compliant in /usr/ucb
export PATH=/usr/xpg4/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:${opt_path}:${solaris_opt_path}
#
# HP-UX is Posix-compliant with
export UNIX95=
#
# GREP_OPTIONS can obscure GNU grep
unset GREP_OPTIONS
#
# LD_* can obscure external commands
unset LD_LIBRARY_PATH LD_PRELOAD
#
# no glob file-matching in command args and word lists (for loop)
set -f
#
# prefer builtin commands and use Posix-compliant options
# check with "shellcheck"

Ok this is my wisdom. Perhaps you want to add something from your wisdom?
 
MKCOVER(8)						      System Manager's Manual							MKCOVER(8)

NAME
mkcover - HylaFAX continuation cover page generation command SYNOPSIS
/var/spool/hylafax/bin/mkcover qfile template result DESCRIPTION
bin/mkcover is the command invoked by the facsimile server when a continuation cover page is required for an outbound job that is about to be retried. It generates a single POSTSCRIPT(R) page that is imaged according to the remote capabilities and transmitted as the cover page. The arguments are: qfile the job description file for the outbound job. template the cover page template file, as used by the faxcover(1) program. result the filename where the resultant POSTSCRIPT document should be written. The default mkcover command is a shell script that uses awk(1) to parse the job description file and generate the cover page document. The template file may be optionally compressed with compress(1), pack(1), or gzip(1); the filename suffix is used to decide whether or not the template file contains compressed data. SEE ALSO
faxq(8), hylafax-config(5), sendq(5) June 20, 1994 MKCOVER(8)
All times are GMT -4. The time now is 04:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy