Skip to content

Commit

Permalink
Moved usage function, fixed mountlto, unquoted OPTIND
Browse files Browse the repository at this point in the history
  • Loading branch information
dinahhandel committed Oct 15, 2015
1 parent 9da98e4 commit ad33b6d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions formatlto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
version="0.2"

SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/ltofunctions" || { echo "Missing '${SCRIPTDIR}/ltofunctions'. Exiting." ; exit 1 ;};

_usage(){
echo
Expand All @@ -18,6 +17,10 @@ _usage(){
exit
}

. "${SCRIPTDIR}/ltofunctions" || { echo "Missing '${SCRIPTDIR}/ltofunctions'. Exiting." ; exit 1 ;};
dependencies=(mkltfs)


unset MIDDLE_OPTIONS
while getopts ":fh" opt ; do
case "${opt}" in
Expand All @@ -30,7 +33,7 @@ done

if [ ! "${LTO_ARRAY}" ] ; then
if [[ $(uname -s) == "Darwin" ]] ; then
LTO_ARRAY=($(system_profiler SPSASDataType | grep "SCSI Target Identifier" | cut -d : -f2 | xargs)) # try to figure out how many lto decks are attached
LTO_ARRAY=($(system_profiler SPSASDataType | grep "SCSI Target Identifier" | cut -d : -f2 | sort | xargs)) # try to figure out how many lto decks are attached
else
LTO_ARRAY=(0) # to do: itemize when there are multiple lto drives in Linux
fi
Expand Down
2 changes: 1 addition & 1 deletion ltofunctions
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ _report(){
n) ECHOOPT="-n" ;; # to avoid line breaks after echo
esac
done
shift $(( "${OPTIND}" - 1 ))
shift $(( ${OPTIND} - 1 ))
MESSAGE="$1"
echo "${ECHOOPT}" "${COLOR}${START_MESSAGE[@]}${MESSAGE}${NC}"
[ "${LOG}" = "Y" ] && _log -w "${MESSAGE}"
Expand Down
6 changes: 3 additions & 3 deletions mountlto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/ltofunctions" || { echo "Missing '${SCRIPTDIR}/ltofunctions'. Exiting." ; exit 1 ;};


unset "${LTO_ARRAY}"
unset "${LTFS_OPTIONS}"
unset LTO_ARRAY
unset LTFS_OPTIONS
LTO_LOGS="${HOME}/Documents/lto_indexes"
if [[ -z "${LTO_ARRAY}" ]] ; then
if [[ $(uname -s) == "Darwin" ]] ; then
LTO_ARRAY=($(system_profiler SPSASDataType | grep "SCSI Target Identifier" | cut -d : -f2 | xargs)) # try to figure out how many lto decks are attached
LTO_ARRAY=($(system_profiler SPSASDataType | grep "SCSI Target Identifier" | cut -d : -f2 | sort | xargs)) # try to figure out how many lto decks are attached
else
LTO_ARRAY=(0) # to do: itemize when there are multiple lto drives in Linux
fi
Expand Down
5 changes: 3 additions & 2 deletions writelto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ TAPE_MOUNT_POINT="/Volumes"
TAPE_SERIAL_REGEX="[A-Z0-9]\{6\}"
LTO_LOGS="$HOME/Documents/lto_indexes"
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/ltofunctions" || { echo "Missing '${SCRIPTDIR}/ltofunctions'. Exiting." ; exit 1 ;};

_usage(){
echo "writelto"
Expand All @@ -15,6 +14,8 @@ _usage(){
exit 1
}

. "${SCRIPTDIR}/ltofunctions" || { echo "Missing '${SCRIPTDIR}/ltofunctions'. Exiting." ; exit 1 ;};

# command-line options
OPTIND=1
while getopts ":t:" opt ; do
Expand All @@ -24,7 +25,7 @@ while getopts ":t:" opt ; do
:) echo "Option -${OPTARG} requires an argument" ; exit 1 ;;
esac
done
shift $(( "${OPTIND}" - 1 ))
shift $(( ${OPTIND} - 1 ))


SOURCE_DIR="${1}"
Expand Down

0 comments on commit ad33b6d

Please sign in to comment.