11#! /bin/bash
2- set -o nounset # Treat unset variables as an error
3- # set -x
4- VERSION=" 0.1"
2+ set -o nounset # Treat unset variables as an error
53
64# List
75bin_filepath=
@@ -10,11 +8,10 @@ mountpoint_path=
108
119# ##############################################################################
1210# # Help function
13- usage ()
14- {
11+ usage () {
1512 echo " ############################################################"
1613 echo " ##"
17- echo " ## ` basename $0 ` [-I <filepath>] [-O <mountpoint(s)> ]"
14+ echo " ## $( basename " $0 " ) [-I <filepath>] [-O <mountpoint(s)> ]"
1815 echo " ##"
1916 echo " ## Options:"
2017 echo " ## -I: filepath binary to copy"
@@ -32,29 +29,29 @@ if [ $# -lt 2 ]; then
3229fi
3330
3431# Parsing options
35- if [ $1 == " -I" ]; then
32+ if [ " $1 " == " -I" ]; then
3633 shift 1
3734fi
3835
3936bin_filepath=$1
4037
41- if [ $2 == " -O" ]; then
38+ if [ " $2 " == " -O" ]; then
4239 shift 1
4340fi
4441# Strip first and last ""
4542mountpoint_name=" ${2% \" } "
4643mountpoint_name=" ${mountpoint_name# \" } "
4744
48- if [ -z $bin_filepath ]; then
45+ if [ -z " $bin_filepath " ]; then
4946 echo " No binary file path provided!"
5047 exit 1
5148fi
52- if [ -z $mountpoint_name ]; then
49+ if [ -z " $mountpoint_name " ]; then
5350 echo " No mountpoint name provided!"
5451 exit 1
5552fi
5653
57- if [ ! -f $bin_filepath ]; then
54+ if [ ! -f " $bin_filepath " ]; then
5855 echo " $bin_filepath not found!"
5956 exit 2
6057fi
6360IFS=' ,' read -ra mnt_list <<< " $mountpoint_name"
6461for mnt in " ${mnt_list[@]} " ; do
6562 # mnt_path_list=(`cat /proc/mounts | cut -d' ' -f2 | sort -u | grep $mnt`)
66- mnt_path_list=(` df -Hl | grep -v " Mounted on" | rev | cut -d' ' -f1 | rev | sort -u | grep $mnt ` )
63+ mnt_path_list=($( df -Hl | grep -v " Mounted on" | rev | cut -d' ' -f1 | rev | sort -u | grep " $mnt " ) )
6764 if [ ${# mnt_path_list[@]} -ne 0 ]; then
6865 # Ensure to have exact match
6966 for mnt_path in " ${mnt_path_list[@]} " ; do
70- mnt_name=` echo $mnt_path | rev | cut -d' /' -f1 | rev`
67+ mnt_name=$( echo " $mnt_path " | rev | cut -d' /' -f1 | rev)
7168 if [ " $mnt_name " = " $mnt " ]; then
7269 echo " Found '$mnt ' at '$mnt_path '"
7370 mountpoint_path=$mnt_path
@@ -77,14 +74,14 @@ for mnt in "${mnt_list[@]}"; do
7774 fi
7875done
7976
80- if [ -z $mountpoint_path ] || [ ! -d $mountpoint_path ]; then
77+ if [ -z " $mountpoint_path " ] || [ ! -d " $mountpoint_path " ]; then
8178 echo " $mountpoint_name not found."
8279 echo " Please ensure the device is correctly connected and mounted."
8380 exit 3
8481fi
8582
8683# Copy the binary to the mountpoint
8784echo " Copying $bin_filepath to $mountpoint_path ..."
88- cp $bin_filepath $mountpoint_path
85+ cp " $bin_filepath " " $mountpoint_path "
8986
9087exit $?
0 commit comments