To "/" or not to "/".
I have a dilemma over assigning variables for the following shellscript backup program:
Code:
#!/bin/bash
#VARIABLES
#Initialize
unset BOOT DISK0 DISK1 DISK2 SOURCE TARGET1 TARGET2 USER
#Define
#Individual
DISK0=/Sea_ext4
DISK1=/Sea_ntfs
DISK2=/Sam_HM320II
USER=/$(echo $(whoami))
#Composite
SOURCE=/media${USER}${DISK0}/recent
TARGET1=/media${USER}${DISK1}/recent
TARGET2=/media${USER}${DISK2}/recent
#CORE DATA
#Synchronization
rsync -Savi -Eu -stat --delete ${SOURCE}/AC ${TARGET1};
rsync -Savi -Eu -stat --delete ${SOURCE}/AC ${TARGET2};
When assigning the variables above, should I include the "/", e.g.
Code:
DISK1=/Sea_ntfs
DISK2=/Sam_HM320II
or not, e.g.
Code:
DISK1=Sea_ntfs
DISK2=Sam_HM320II
This may seem like an extremely small insignificant matter, but when you include the "/" in the pathname, than
1) in the next section Composite Variables, than you have to look at a morass of several variables lumped together, "/" included; e.g.
Code:
SOURCE=/media${USER}${DISK0}/recent
TARGET1=/media${USER}${DISK1}/recent
rather than "/" excluded; e.g.
Code:
SOURCE=/media/${USER}/${DISK0}/recent
TARGET1=/media/${USER}/${DISK1}/recent
2) in the main code, you have pathnames starting out without any "/", e.g.
Code:
rsync -Savi -Eu -stat --delete ${SOURCE}/AC ${TARGET1};
rather than "/" excluded from the individual path name variables; e.g.
Code:
rsync -Savi -Eu -stat --delete /${SOURCE}/AC /${TARGET1};
With the colorized themes that most IDEs provide, seeing a different colored "/"
1) between the two variables
2) before pathnames
can make the code more clear, and can make the usual boring morass become alive.
Is there some programming board/standard (e.g. POSIX) that advises programmers of a standard of whether or not to include the "/" in the Individual Variable names?