Article 51QJH What is the "Best Practice" When Using a Positional Parameter?

What is the "Best Practice" When Using a Positional Parameter?

by
Steve R.
from LinuxQuestions.org on (#51QJH)
I have the following code snippet. This code snippet is essentially duplicated in several places for different uses.

Code:# Set Backup Log Name Extension
if [ $1 -eq 0 ]
then
log_extension="incremental_backup_log.txt"
backup_type="Incremental"
else
log_extension="full_backup_log.txt"
backup_type="Full"
fiI was wondering, as a "best practice", if the value of "$1" should be immediately assigned to a variable (at its first use) so that it ("$1") is not used again in the script. See example below.

Code:# Set Backup Log Name Extension
backup_style=$1
if [ backup_style -eq 0 ]
then
log_extension="incremental_backup_log.txt"
backup_type="Incremental"
else
log_extension="full_backup_log.txt"
backup_type="Full"
filatest?d=yIl2AUoC8zA latest?i=_bZC3nDinvo:SMpce2o94Tk:F7zBnMy latest?i=_bZC3nDinvo:SMpce2o94Tk:V_sGLiP latest?d=qj6IDK7rITs latest?i=_bZC3nDinvo:SMpce2o94Tk:gIN9vFw_bZC3nDinvo
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments